Forum Moderators: open

Message Too Old, No Replies

How do I get this JavaScript to execute in the panel?

         

pityocamptes

9:40 pm on Dec 18, 2009 (gmt 0)

10+ Year Member



I found this html panel (<snipped url>) and I got it working. However, instead of text running in the panels I would like to execute one, two, etc. scripts within the panels (news, scripts, etc). How do I get this to work? Thoughts? Thanks!

THIS WORKS

//fill the contents of the new tab's panel
newTabPanel.innerHTML = "News Content";

THIS DOES NOT

//fill the contents of the new tab's panel
newTabPanel.innerHTML = "<script type="text/javascript" src="http://cdn.example.com/syndication/subscriber/InsertWidget.js"></script><script>if WIDGET) WIDGET.renderWidget('e2945c57-ab31-42c7-ac07-00369856e292');</script><noscript>Get the <a href="http://www.example.com/widget/meta...-inocom">Metal Futures Quotes - example.com</a> widget and many other <a href="http://www.example.com/">great free widgets</a> at <a href="http://www.example.com">Widget</a>! Not seeing a widget? (<a href="http://docs.example.com/using-widg...-widget/">More info</a>)</noscript>";

[edited by: whoisgregg at 7:13 pm (utc) on Dec. 21, 2009]
[edit reason] Removed specifics, please use "example.com" Thanks! :) [/edit]

whoisgregg

7:19 pm on Dec 21, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, pityocamptes!

In order to inject JavaScript code into the page, you have to eval() the new code. If you want to be able to mix regular HTML and <script> blocks when updating the content of a <div> then I'd recommend taking a look at how the open source javascript libraries provide that functionality.

I know Prototype, jQuery, and the YUI Library all offer this functionality. Even if you don't want to just take advantage of those entire libraries, you can still peak at their code for how to do it yourself.