surps has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, I would like print the values using a perl program. The data entered in the form will be within iframe tag. Please cut this html code and provide to write a small perl program to catch values.
<HTML> <HEAD> <title>Say....</title><script language="JavaScript" type="text/javascr +ipt"> <!-- // --> </script> </head> <BODY TEXT="#000000" BGCOLOR="#EFF3FC" leftmargin="0" topmargin="0" ma +rginwidth="0" marginheight="0" LINK="#0000CC" VLINK="#0000CC" ALINK=" +#0000CC"> <A NAME=pagetop></A> <TABLE BGCOLOR="#FFFFFF" BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDI +NG=2> <TR BGCOLOR="#ABABAB" > <TD ALIGN=left> </TD> <TD ALIGN=right><b></b></TD> </TR> <TR> <TD valign="bottom" BGCOLOR="#88A2E2" height="29"> <FORM name=compose action="one.cgi" METHOD=POST ENCTYPE="multipart/for +m-data"> <STYLE TYPE="text/css"> TABLE#tblCoolbar { background-color:threedface; padding:1px; color:menutext; border-width:1px; border-style:solid; border-color:threedhighlight threedshadow threedshadow threedhighl +ight; } .cbtn { height:18; BORDER-LEFT: threedface 1px solid; BORDER-RIGHT: threedface 1px solid; BORDER-TOP: threedface 1px solid; BORDER-BOTTOM: threedface 1px solid; } .txtbtn {font-family:tahoma; font-size:70%; color:menutext;} </STYLE> <script LANGUAGE="JavaScript"> function button_over(eButton) { eButton.style.backgroundColor = "#B5BDD6"; eButton.style.borderColor = "darkblue darkblue darkblue darkblue"; } function button_out(eButton) { eButton.style.backgroundColor = "threedface"; eButton.style.borderColor = "threedface"; } function button_down(eButton) { eButton.style.backgroundColor = "#8494B5"; eButton.style.borderColor = "darkblue darkblue darkblue darkblue"; } function button_up(eButton) { eButton.style.backgroundColor = "#B5BDD6"; eButton.style.borderColor = "darkblue darkblue darkblue darkblue"; eButton = null; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ var isHTMLMode=false function document.onreadystatechange() { idContent.document.designMode="On" } function cmdExec(cmd,opt) { if (isHTMLMode){alert("Please uncheck 'Edit HTML'");return;} idContent.document.execCommand(cmd,"",opt);idContent.focus(); } function setMode(bMode) { var sTmp; isHTMLMode = bMode; // alert(bMode); if (isHTMLMode){sTmp=idContent.document.body.innerHTML;idContent.d +ocument.body.innerText=sTmp; //alert(sTmp); } else {sTmp=idContent.document.body.innerText;idContent.document.bo +dy.innerHTML=sTmp;} idContent.focus(); } function setSubmit(bMode) { var sTmp; isHTMLMode = bMode; if (isHTMLMode) { sTmp=idContent.document.body.innerHTML; alert(sTmp); } } </script> <iframe width="542" id="idContent" height="350"></iframe> <br> <input type="submit" name ="HERE" value="HERE"> </FORM></BODY></HTML>
Thanks

Edit: Added <code> tags. larsen

Replies are listed 'Best First'.
Re: How can i catch the values within iframe tag using perl
by nothingmuch (Priest) on Nov 17, 2002 at 18:19 UTC
    <iframe> tags work by opening a nested page of another source, within a document, not within a frame set, but more like an embeded object (like an image). This particular one is getting it's location from a javascript. In general what you want can't be done 'correctly' without having a javascript interpreter in your script. But this one's tougher.

    Since the source of the iframe in this page is not hard coded, or even calculated, but instead the contents of the iframe is overwritten by assigning to the browser objects representing it. I can't see it being done In any way other than writing a limited javascript interpreter.

    You'll probably be better off obtaining a book or reading some tutorials on javascript, in attempts to translate the code to perl, or use a browser in some odd way (varies widely to wildly depending on your OS of choice) for it's builtin javascript capabilities.

    -nuffin
    zz zZ Z Z #!perl
      I can't see it being done In any way other than writing a limited javascript interpreter.
      Apropos this rather bizarre route: I noticed that there is a JavaScript interpreting module on CPAN. I haven't actually even tested it, but it might be worth a look. >P>It appears to be an interface to a JavaScript interpreter from <mozilla.org>.

      Oh, and on first sight it looks it's barely even documented, but if you go to the "browse" section, you'll see a "JavaScript.pod" file there. Apparently, the tiny bit of POD in the .pm file has confused <search.cpan.org>. Plus: if you scroll down in the page with the files listing, there's a plain text version at the bottom of the page.