I have some simple JavaScript functions:
function focus(id)
{
var e = document.getElementById(id);
if (e != null)
{
e.focus();
}
}
function show(id)
{
var e = document.getElementById(id);
if (e != null)
{
e.style.display = "inline";
}
}
I then have an html <a> tag with an onclick event:
<a title="Click This" onclick="focus('some_textbox'); show('some_panel');">Click This</a>
When I click on the "Click This" link, only the show() method executes. From some reason the focus method is never called. Any ideas why this is happening?
I've tried clearing my cache and have reversed the order of the focus() and show() methods. I've also verified that everything is spelled correctly.
Is it because focus() is already a function within JavaScript?
Edit: I tried renaming the function to focus2 and it seems to work now. Very strange. Anybody have any insight into why this happens?
showis executed,focusis as well, maybe you cannot see the effect, maybe it is not the function you defined, but it is executed.focus, see if that worksshowis called afterfocus. Do you think the interpreted just skips a statement? And iffocuswould throw an error or not exist,showwouldn't be executed. Edit: Regarding your last comment, that means that thefocusfunction you called was not the one you defined (and that's actually what I meant). Some engines don't let you override certain global properties.