Using JavaScript with innerHTML

I'm stumped about the use of innerHTML.  I have a series of RSS feeds that I only want to show when a user clicks a button.  In order to make this work, I think I need to use innerHTML -- so I can control where on my website the RSS will appear.

Here's the JavaScript code I want to use:
<script language="JavaScript" src="" type="text/javascript"></script>

Yet when I try to incorporate the above code into innerHTML, I get nothing.  

getElementById('RSSdisplay').innerHTML="<script language='JavaScript' src='' type='text/javascript'></script>";

<td id = "RSSdisplay"></td>

Can anyone give me a generic example of how to use the code above with innerHTML?

Thank You!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ZvonkoSystems architectCommented:
Like this:

<td id = "RSSdisplay">
<script language="JavaScript" src="" type="text/javascript"></script>

ZvonkoSystems architectCommented:
And the explanation is this: you cannot assign the script to innerHTML because it is NOT HTML but script.
So you either have to set the script into an invisible div and let the script produce the resulting html inside that invisible div and copy afterwards the invisible div innerHTML to your destination TD.innerHTML.
Or you place the script inside the TD where you need the generated html.
But you cannot pipe the script written html directly to destination TD.

marcparilloAuthor Commented:
Thanks -- but I need to be able to call the RSS feed through a JavaScript function.  I tried this but it doesn't work.  

   <script language="JavaScript">
   function displayRSS()
var link = "''";
document.write("<script language = 'JavaScript' type='text/javascript'>"+"src="+link+"</script>");

Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

ZvonkoSystems architectCommented:
That is a common pitfall.
You have to split the script tag:

document.write("<scr"+"ipt language = 'JavaScript' type='text/javascript' src="+link+"></scr"+"ipt>");

And in your upper comment you placed the src outside of the script tag.

marcparilloAuthor Commented:
Thanks Zvonko -- I send that last reply before I read your explanation.  Thank you for helping me clear this up.  Can you show me an example of setting the script into an invisible DIV and would I be able to call it on command with a button?
marcparilloAuthor Commented:
Wow -- your ---<scr"+"ipt --- example worked!!  Thank you, Thank you, Thank you!

Why do I have to split up the <script> tag like that?  I have never seen that before.

ZvonkoSystems architectCommented:
You are welcome.
And you have to split the script tage because of the fact that all script is first written on a html source page. So the html parser has a problem to distinguish between embedded script tags. By rewritting the inner script tag strings you help the html parse to ignore them as script tags at first scan and interpret them after they are written by document.write()

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.