View Full Version : Using Javascript variable in src tag?

10-17-2006, 08:56 PM
Hello all..
I am trying to use a Javascript variable in the src tag of a iframe thus loading the correct page in the iframe based on the variable.

I have so far been able to do a document.write(argument) and I can see the correct variable written out....I just need to get it into that src!!

Thanks in advance!

10-17-2006, 09:23 PM
Nevermind....figured it out.

Not sure if it was the best way...but I just did a document.write of the line of html code with the variable in there. :D

10-18-2006, 06:45 PM
That's one way. A better one is to have the src originally set to a suitable default variable for non-JS browsers, then change it with a <script> later on in the document (or using onload).