Get hi-est zIndex on the page

G

George Hester

I mean right-click. Sorry for the dyslexia attack.

--
George Hester
__________________________________
Well I do it with activeElement. Like this:

if (document.activeElement.getAttribute('id') == 'oBody'){
oBody.focus();
} else if (document.activeElement.getAttribute('id') == 'UID'){
ctrlUID.focus();
......
}

In this case there are two elements on the page oBody obviously the id for the body element (that is your active element when the Context Menu closes) and ctrlUID that is a text box with id = 'UID'. I believe in your case you could change oBody.focus() to ctrlUID.focus();. I actually have to do this throughout my control scripts (on 2 of them) because I get a nasty bug (IE 5.5) where key down events don't fire on the first keydown. But require two keydowns before the keydown event fires correctly. It's a bitch and this that you see above is my workaround for the issue. Likely an array holding all the 'ids' on the page would be a better soulution or a switch. Yeah maybe let me try that. Thanks a switch that'll do it.

Oh but the lett-click oh crap. I don't know I gave up on that. I couldn't get the left-click on keydown to fire correctly. Sorry no HTH but I tried.
 
G

George Hester

Yeah I got it. The right-click does not cause the onclick to fire in the document. Only the left click. What happens is you are setting the right-click of the mouse to false so that you can get your own context menu. So you have this in the body tag:

<body ... oncontextmenu="JavaScript:return false;">

What we need is redirect this onconetxtmenu first. Just think of it as a onrightclick hardy har har. So to get the text box to have focus after(before) the context menu pops up:

<body ... oncontextmenu="JavaScript:ctrlTxt.focus(); return false;">

where:
<input id="ctrlTxt" type="text" value="test"/>

Now of course you might want to use the previous activeElement test I gave you as a switch I believe. And you may need to put the script in the ContextMenu not sure. HTB. - strictly IE.
 
D

DJ WIce

Well I do it with activeElement. Like this:

if (document.activeElement.getAttribute('id') == 'oBody'){
oBody.focus();
} else if (document.activeElement.getAttribute('id') == 'UID'){
ctrlUID.focus();
......
}

Thanks, I did not know that "activeElement" was an object!
Thanks,
Wouter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top