0

I'm using JS to build some HTML that includes the new iframe syntax from YouTube.

When someone clicks a link on the page to a YouTube video, JS checks the document size and if it's big enough, will open up a lightbox-style box on the page and play the video there.

When I test it out, it opens the HTML but the space is just white and the source code shows an empty <iframe> element.

Is there a problem with trying to dynamically add an iframe to a page?

Here is the relevant part of the JS:

iframe = '<iframe width="'+defaults.width+'" height="'+defaults.height+'" src="'+vidsrc+'" frameborder="0" allowfullscreen></iframe>';
container = '<div class="videopow-overlay"><div class="videopow-container">' + iframe + '</div></div>';

$("body").prepend( container );

Here is what gets output:

<div class="videopow-overlay">
  <div class="videopow-container">
    <iframe width="800" height="485" src="http://www.youtube.com/watch?v=phzvyIQWCo8?hd=1" frameborder="0" allowfullscreen="">
      <html><head></head><body></body></html>
    </iframe>
  </div>
</div>
1
  • can you post your vidurl, i think there is a problem. Commented May 20, 2011 at 18:48

1 Answer 1

1

Change vidsrc from:

http://www.youtube.com/watch?v=phzvyIQWCo8?hd=1

to

http://www.youtube.com/embed/phzvyIQWCo8?hd=1
Sign up to request clarification or add additional context in comments.

1 Comment

Oh god that was totally it. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.