in reply to Re: Java script question
in thread Java script question

It still dies on the pop according to Visual Dev editor. that may mean absolutly nothing however.

Replies are listed 'Best First'.
Re: Re: Re: Java script question
by drfrog (Deacon) on Aug 03, 2001 at 00:06 UTC
    one thing you should use to debug this is netscape!

    type in
    javascript:
    in the url field
    gets you the javascript debugger
    it should tell you what the error is
    in a much clearer way than ie and/or visualdev would

    one thing:
    you dont need the
    javascript:
    if the javascript function is in the html file {or perl output}
    aka
    onmouseover=pop('Avaerage lenght of game played','#CCCCCC')

    also you might notice the semi colon after your dbl quote
    thats not right and since your only using one
    function , in javascript you dont need that semi colon

    here is your code reworked and running:
    <html> <head> <script> function kill() { alert('kill'); } function pop (text, color) { alert (text +" "+ color); } </script> </head> <body> <a href="js.html" ONMOUSEOVER="pop('Avaerage lenght of game played','# +CCCCCC')" ONMOUSEOUT="kill()">AVERAGE</a> </body> </html>

    always try to build a flat file to test javascripts
    before inserting them into perl code
    hope that helps
Re: Re: Re: Java script question
by !me (Acolyte) on Aug 02, 2001 at 22:33 UTC
    Well, If it is still generating errors you probably should post the pop and/or kill functions. I tested the small (corrected) block above and it worked fine for me ( using fake pop/kill functions )
      Here is the pop and kill function snipped straight from the cgi. Thanks for your help !me.
      <style TYPE="text/css"> <!-- body{ overflow:scroll;overflow-x:hidden } .popper { position : absolute; visibility : hidden; } //--> </style>
      <SCRIPT> var nav = (document.layers); var iex = (document.all); var skn = (nav) ? document.topdeck : topdeck.style; if (nav) document.captureEvents(Event.MOUSEMOVE); document.onmousemove = get_mouse; function pop(msg,bak) { var content ="<TABLE WIDTH=130 BORDER=0 CELLPADDING=2 CELLSPACING=0 BG +COLOR=#000000><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSP +ACING=0><TR><TD><CENT ER><FONT COLOR=#FFFFFF SIZE=2><B>Detailed Info</B></FONT></CENTER></TD +></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 +BGCOLOR="+bak+"><TR>< TD><FONT COLOR=#000000 SIZE=2><CENTER>"+msg+"</CENTER></FONT></TD></TR +></TABLE></TD></TR></TABLE>"; if (nav) { skn.document.write(content); skn.document.close(); skn.visibility = "visible"; } else if (iex) { document.all("topdeck").innerHTML = content; skn.visibility = "visible"; } } function get_mouse(e) { var x = (nav) ? e.pageX : event.x+document.body.scrollLeft; var y = (nav) ? e.pageY : event.y+document.body.scrollTop; skn.left = x - 60; skn.top = y+20; } function kill() { skn.visibility = "hidden"; } </SCRIPT>
        First thing I would do is compare the output of the cgi to the html embedded within the cgi, make sure its not getting mangled. Second, you might want to make sure the JavaScript doesn’t start until the body is loaded by either

        1. Moving the script to after the body tags
        2. Wrapping the main part of the script within a function call that is called after the body ( or target object ) loads.