dynamically add embedded object link (e.g. video player)
Hi,
I have an html page that initially gets loaded with an "empty" div like this:
<div id="video_div"><img/></div>
In my application, I will pull out the entire embedded video URL from a source such as YouTube. An example of how this URL looks like:
<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/kSVrJAbwKdQ&hl=en&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/kSVrJAbwKdQ&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>
I would like to replace that blank <img/> element in the "empty" div with something like the above. I've looked at stuff like replaceChild and such but I'm not sure how to just drop that entire <object.... in the empty div. Any ideas? Thanks.
-los
Try this :
<head>
<script>
function YouTube() {
document.write('<object width=425 height=344><param name=movie value="http://www.youtube.com/v/kSVrJAbwKdQ&hl=en&fs=1&"><param name=allowFullScreen value=true><param name=allowscriptaccess value=always><embed src="http://www.youtube.com/v/kSVrJAbwKdQ&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess=always allowfullscreen=true width=425 height=344></embed></object>')
}
</script>
</head>
<body>
<div id="video_div">
<a href=# onclick=YouTube()><img src="pic.gif" alt="Click img Here"></a>
</div>
</body>
If you are loading flash objects you could try swfobject.
http://code.google.com/p/swfobject/
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks