views:

45

answers:

2

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="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.

Thanks, Dave

A: 

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>
Kunal
To be clear, the entire highlight() function works. I did this by calling `highlight('mod_sup_div', true);` followed immediately by `setTimeout('highlight(\'mod_sup_div\', false)',5000);'5 seconds after the div presents itself, it disappears. The problem is that I want to call the fade function from inside the mod_sup_div. If I create an `onclick="highlight('mod_sup_div',false)"` on any element, the event is not triggering the function, nor any other function. This is really more of an event triggering problem than anything.Thanks for the help so far.--Dave
the Hampster
Dave, What I meant was onclick="highlight( 'mod_sup_div', false ) works for the span in question in my test. No doubt Event is triggering the function. However it looks like there could be some error which is preventing the function to continue.Have you tried the test after enabling FireBug? See what you get! I'm sure you would get some javascript error.
Kunal
A: 

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.

the Hampster