Problem writing code to div tag

liunx

Guest
I have been getting an error when I try to do the following:<br />
<br />
<html><br />
<br />
<head><br />
<script><br />
<br />
function doit()<br />
{<br />
var str2 = "<script> alert('HOLA'); </script>";<br />
var adiv = document.createElement("DIV");<br />
adiv.innerHTML = str2;<br />
document.body.appendChild(adiv);<br />
}<br />
<br />
</script><br />
</head><br />
<body><br />
<br />
<input type="button" name="at" value="Button" onClick="doit();"><br />
<br />
</body><br />
</html><br />
<br />
I get an "Unterminated string constant error." <br />
Does anybody have an idea to what is wrong here?<br />
Is is possibly the "</script>" tag causing this? <br />
<br />
Thanks in advance.<!--content-->try this<br />
<html><br />
<br />
<head><br />
<script><br />
<br />
function doit()<br />
{<br />
var str2 = alert('HOLA');<br />
var adiv = document.createElement("DIV");<br />
adiv.innerHTML = str2;<br />
}<br />
<br />
</script><br />
</head><br />
<body><br />
<br />
<input type="button" name="at" value="Button" onClick="doit();"><br />
<br />
</body><br />
</html> <br />
<br />
Hope this is what you are looking for<br />
Bonkom :pimp:<!--content-->Continued in: <!-- m --><a class="postlink" href="http://www.htmlforums.com/showthread.php?s=&threadid=20624">http://www.htmlforums.com/showthread.ph ... adid=20624</a><!-- m --><br />
<br />
Riemino, Please do not double post your messages.<!--content-->
 
Back
Top