471,093 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,093 software developers and data experts.

javascript variable in html tag

Hi all

I've got a html doc with <embed src="url.svg"> in it

however, I'd like the source to be a javscript variable (which will
depending on an if, be a different filename on loading)

is this possible and if so, what is the syntax to put a javascript variable
inside an embed tag?

thanks
Jul 23 '05 #1
1 3504
Tim J wrote:
Hi all

I've got a html doc with <embed src="url.svg"> in it

however, I'd like the source to be a javscript variable (which will
depending on an if, be a different filename on loading)

is this possible and if so, what is the syntax to put a javascript variable
inside an embed tag?

thanks


window.onload= setEmbedSrc;

function setEmbedSrc(){
if (condition){
newFileName = 'someFile1.svg';
}else{
newFileName = 'someFile2.svg';
}
document.getElementById('myDeprecatedEmbedTag').sr c=newFileName;
}

<embed id="myDeprecatedEmbedTag" src="whoCaresIAmGoingToChangeItAnyway.svg">

Untested. Its Midnight, I am too lazy to test.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.