Sigh.. I got another problem And there isn't a lot of info about perlscript...
Consider the following code:
Code:
<HTML>
<HEAD>
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<SCRIPT LANGUAGE=PerlScript>
$doc = $window->document;
sub mydynbody {
$objMyBody = $doc->getElementsByTagName("BODY")->item(0);
$objButton = $doc->createElement("INPUT");
$objButton->setAttribute("id","mybutton");
$objButton->setAttribute("value", "Go");
$objButton->setAttribute("type", "button");
$objButton->setAttribute("onclick", "klik()");
$objMyBody->appendChild($objButton);
}
sub klik {
$doc->write("<H1>Klik!</H1>");
}
sub dbg {
$window->alert($doc->body->outerHTML);
}
1;
</SCRIPT>
<TITLE>test</TITLE>
</HEAD>
<BODY onLoad="mydynbody()">
<INPUT TYPE=button VALUE="Debug" onclick="dbg()">
</BODY>
</HTML>
The Debug button works as it should. The dynamicly created klik button doesn't. It shows up but the onclick event doesn't fire up the klik() sub. Digging around I found this article. It seems IE doesn't like it done this way. They've solved this by using new Function("klik()"); in JavaScript.
So what is the PerlScript equivalant of JavaScript's new Function?