Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
disabling keys with FormAPI/Javscript
Johnny
We've had a common complaint that users have accidently sometimes found themselves outside a text field, hit backspace and hence invoked a browser back.
Browsing functions like backspace, F5 can be pitfalls in a browser interface like forms publisher.
We tried to introduce some javascript that would catch these events (IE only).
They work fine on a test html page, but once i try to put it into a DCT they dont seem to work.
Now I know javascript is supposed to be used only in context of FormAPI, but this would be a real big plus in terms of usability.
I've posted a test html page and a test DCT, the javascript code is the same but only works in the html page.
It does try to hook into document.onkeydown, maybe an IWOVer can give some feedback on the inner workings of the DCT screen.
John Cuiuli
Find more posts tagged with
Comments
Dwayne
My guess is that this isn't working because, in essense, you're setting the event handler for the script frame, rather than the frame that contains the form. You might try something like this: (approximation of code - I haven't tested this)
--
Current project: TS 5.5.2/6.1 W2K
Johnny
Ofcourse!.. **** frames.
Didn't even occur to me.
I think you have the right idea, but I haven't got it yet.
I've tried finding the frame holding the form frame using
window.parent
parent
top
top._dcWin
top._dcWin.formframe
Still looking, it's like a maze trying to find this stupid thing!!
John Cuiuli
JonathonG
Hey Johnny, I know this thread is a bit old, but did you ever figure this out? I don't want to spend too much time trying to chase it down if you've already got it. Any help would be appreciated.
Thanks,
Jonathon
Interwoven Developer
Allstate, Inc.
Migrateduser
When you say "finding", are you just guessing or are you testing output of something like:
for (var i=0; i<=top.all.length;i++) {
alert(top.all [ i ].name + ': ' top.all['i'].value);
}
... or something similar? I've found lots of nice quasi-hidden things this way!
Dave
Current Environment(s):
(1) TS 6.1 SP2 on W2K3
(2) TS 6.1 SP1 on W2K
(3) TS 6.1 SP2 on Win2K
Johnny
unfortunately no.
I'm convinced that I found the right frame, but there must be some funky javascript that runs before/after the formAPI code which invalidates it.
I think these little extra features can add a lot of value. That being moving away from a web browser to a client application. Applications that use a browser for their GUI normally have no use for the backspace key in the traditional browser sense. That's because they do not contain traditional browser content.
It's not common, but sometimes a user may believe they are in a editable field, hit the backspace and all of a sudden a frame or two disapears on the screen. That could/should be fixed I think.
John Cuiuli
JonathonG
Ok, I found it....sorta.
If you've only got one page, and you have an 'onforminit' handler, adding the following code to that handler will enable you to catch the buttons on that one page:
...
window.parent.formframe.document.onkeydown = handleKeyDown;
...
Then, you must create the handleKeyDown function. The key to handling the event is to remember that the event occurred in a different frame than the one your script is in. So, you have to get the event from the correct frame:
function handleKeyDown()
{
var eventObj = window.parent.formframe.event;
// Do something with the event object
}
Like I said, this works if you have only 1 page, or on the first page of a multi-page template. For some reason, when you navigate to the second page, the event handler is lost. I didn't dig and find a way to know when the page changes, but I suppose one could try to figure out how to plug into that. If anyone does figure that out, please post it, as I would be interested in seeing it.
Jonathon
Interwoven Developer
Allstate, Inc.
Johnny
Ahhh that makes total sense, because all of the text fields i was testing against were on another page!
formframe was the one I coded for, but the multi page DCT is what got me.
Good observation.
John Cuiuli