Dear monks

I know that is not completely a Perl question but only related. My problem is that I'm unable to understand how to embed js in a CGI.

In my intention I want to create a link or an image and when you pass the mouse over it will pop-up a little explanatory table.

I have yet used js in a CGI in this way:
print <<EOSCR; <input type=button value=" ping " onclick="window.open('ping.cgi?host +=$host','Windowname','resizable,width=300,height=150');"> &nbsp;&nbsp;&nbsp;&nbsp <input type=button value=" modifica " onclick="window.open('e.cgi?mac +china=$ciccio[0];numero=$ciccio[1]','Windowname','resizable,scrollbar +s=yes,width=450,height=600');"> EOSCR
But now is different: this function have to be recallable in any point of the script passing it some values.

I have found this example in javascript that run and seems to be very near to my wishes:
<html> <head> <STYLE TYPE="text/css"> .D11 { POSITION:absolute; VISIBILITY:hidden; Z-INDEX:200; } </STYLE> <SCRIPT TYPE="text/javascript"> Xoffset=-60; Yoffset= 20; var isNS4=document.layers?true:false; var isIE=document.all?true:false; var isNS6=!isIE&&document.getElementById?true:false; var old=!isNS4&&!isNS6&&!isIE; var skn; function initThis() { if(isNS4)skn=document.d11; if(isIE)skn=document.all.d11.style; if(isNS6)skn=document.getElementById("d11").style; } function popup(_m,_b) { var content="<TABLE WIDTH=130 BORDER=1 BORDERCOLOR=black CELLPADDIN +G=2 CELLSPACING=0 "+"BGCOLOR="+_b+"><TD ALIGN=center><FONT COLOR=blac +k SIZE=2>"+_m+"</FONT></TD></TABLE>"; if(old) { alert("You have an old web browser:\n"+_m); return; } else { if(isNS4) { skn.document.open(); skn.document.write(content); skn.document.close(); skn.visibility="visible"; } if(isNS6) { document.getElementById("d11").style.position="absolute"; document.getElementById("d11").style.left=x; document.getElementById("d11").style.top=y; document.getElementById("d11").innerHTML=content; skn.visibility="visible"; } if(isIE) { document.all("d11").innerHTML=content; skn.visibility="visible"; } } } var x; var y; function get_mouse(e) { x=(isNS4||isNS6)?e.pageX:event.clientX+document.body.scrollLeft; y=(isNS4||isNS6)?e.pageY:event.clientY+document.body.scrollLeft; if(isIE&&navigator.appVersion.indexOf("MSIE 4")==-1) y+=document.body.scrollTop; skn.left=x+Xoffset; skn.top=y+Yoffset; } function removeBox() { if(!old) { skn.visibility="hidden"; } } if(isNS4) document.captureEvents(Event.MOUSEMOVE); if(isNS6) document.addEventListener("mousemove", get_mouse, true); if(isNS4||isIE) document.onmousemove=get_mouse; </SCRIPT> </head> <body> <DIV ID="d11" CLASS="d11"></DIV> <TABLE BORDER=0 CELLPADDING=40 CELLSPACING=0 SUMMARY="holder"> <TR> <TD ALIGN="center"><A HREF="#" ONMOUSEOVER="popup('<font color=yel +low>Text Inside PopUp</font>','green')" ONMOUSEOUT="removeBox()">Something +of interest</A></TD> </TR> </TABLE> <script> initThis(); </script> <BR><center><a href='http://www.js-examples.com'>JS-Examples.com</a></ +center> </body> </html>
Thanks for the attention

cheers from Roma

Lor*

UPDATE:
I have put the java code in a java.js file and triyng this:
use CGI qw (:all -nph); print header(); print start_html(-title=>'JAVA TEST',-script=>{ -src=> 'java.js'}); my @ar = qw (alpha beta gamma delta); foreach my $it (@ar) { print table(Tr(td(a({-href=>"#",-onMouseOver=>"popup(b($i),'green')", +-onMOuseOut=>"removeBox()"},$it)))); } print end_html();

Not run in any case. Any ideas ?

jdporter unconsidered.
Keep: 14, Edit: 6, Reap: 8
Considered by aukjan: "Not a perl question"


In reply to JS in a CGI: unable to find a solution by Discipulus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.