www.webdeveloper.com
Results 1 to 3 of 3

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

  1. #1
    Join Date
    Jul 2009
    Posts
    1

    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

  2. #2
    Join Date
    Feb 2006
    Posts
    90
    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>

  3. #3
    Join Date
    Jan 2009
    Posts
    3,346
    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
  •  
HTML5 Development Center



Recent Articles