Results 1 to 3 of 3

Thread: dynamically add embedded object link (e.g. video player)

  1. #1
    Join Date
    Jul 2009

    dynamically add embedded object link (e.g. video player)


    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.


  2. #2
    Join Date
    Feb 2006
    Try this :


    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>')



    <div id="video_div">
    <a href=# onclick=YouTube()><img src="pic.gif" alt="Click img Here"></a>


  3. #3
    Join Date
    Jan 2009
    If you are loading flash objects you could try 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
HTML5 Development Center

Recent Articles