« Return to Thread: Dynamically adding new

by ccoroom :: Rate this Message:

Reply to Author | View in Thread

Hi,
I have another form of error when I tried to create a new <script> element dynamically.

HtmlUnit cannot create a new <script> element that defines variable message.
This problem occurs with all types of browsers: IE6, IE7, and FF2.

I'm working with HtmlUnit 2.2 snapshot with forked version of Rhino(2.2 Snapshop).

Here's my code:
----
<html>
<head>
        <script type="text/javascript" src="./add.js"></script>
        <script type="text/javascript">
                add();
        </script>
</head>
<body>
        <input type="button" value="hello" onclick="alert(message);"/>
</body>
</html>
----
//add.js
function add() {
        return document.writeln('\t<script type="text/javascript" src="./hello.js"></script>');
}
----
//hello.js
var message ='hi, there!';
----

Regards,
Sung-Ahn Kim.

 « Return to Thread: Dynamically adding new