Solved Javascript in to innerhtml w/out interfering

August 7, 2011 at 06:41:15
Specs: N/A, N/A
Javascript in to innerhtml w/out interfering with it's script tag please look
Example
<script type="text/javascript">
function we()
{
document.getElementById("stuff").innerHTML="<a href="http://www.showmyweather.com/" title="Show My Weather Forecast" onclick="window.open(this.href);return(false);"><script type="text/javascript" src="http://www.showmyweather.com/weather_widget.php?int=0&type=js&country=us&state=Delaware&city=Wilmington&smallicon=1¤t=1&forecast=1&background_color=ffffff&color=000000&width=175&padding=10&border_width=1&border_color=000000&font_size=11&font_family=Arial&showicons=1&measure=F&d=2011-08-06"></script></div>";
}

</script>

The </script> in the inner HTML makes it think I'm ending the function and whole script instead I obviously want to enter that paragraph "stuff". Our there any ways to work around this???

See More: Javascript in to innerhtml w/out interfering

Report •


#1
August 14, 2011 at 13:52:44
✔ Best Answer
I've always had to fight tooth and nail to get anywhere with something like that; As a result, I tend to try something like:

var js = document.createElement("SCRIPT");
var at = document.createElement("A");

at.href = "some link";
at.title = "some title";
at.onClick = some event;
at.innerHTML = "some link text";

js.src = "some source";

document.getElementById("stuff").appendChild(js);
document.getElementById("stuff").appendChild(at);

HTH


Report •
Related Solutions


Ask Question