Event not triggering
I have no idea where to start on this one. I have a <div>
that does not appear until a button is clicked. This function call works: onclick="highlight('mod_sup_div', true);"
function highlight(aDiv,show) {
if (show) {
Effect.Appear('Overlay',{duration: 0.5, to: .80});
Effect.Appear(aDiv,{duration: 0.5})
}
else {
Effect.Fade('Overlay',{duration: 0.5, to: .80});
Effect.Fade(aDiv,{duration: 0.5})
}
}
In the <div>
I have a button to close the window.
<p class="closer"><span onclick="highlight('mod_sup_div',false)">X</span></p>
This does not work. The function is not even called, as I made a alert()
the first line of the function at it does nothing.
What is odd, is that onclick=开发者_StackOverflow社区"Effect.Fade(aDiv,{duration: 0.5})"
does work. Other simple Javascript functions in the onclick="" work, except for the function call.
Any help as to why this is happening would be very appreciated.
This works perfectly in Firefox
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<SCRIPT type="text/javascript">
function highlight(aDiv,show)
{
if (show) {
/*Effect.Appear('Overlay',{duration: 0.5, to: .80});
Effect.Appear(aDiv,{duration: 0.5}) */
alert("Show");
}
else {
/*Effect.Fade('Overlay',{duration: 0.5, to: .80});
Effect.Fade(aDiv,{duration: 0.5}) */
alert("hide");
}
}
</SCRIPT>
</HEAD>
<BODY>
<p class="closer"><span onclick="highlight('mod_sup_div',false)">X</span></p>
</BODY>
</HTML>
Sorry it's been a while, many other things to rewrite/fix.
It appears that highlight is either a keyword, or something internal to Prototype or Scriptaculous. Changing the name of the function solved the whole things. What is odd, is that I have a function named goto() and it works great!
I have noticed that if I send improper information to Prototype.js, it simply fails with no explanation. Thanks for the help.
精彩评论