SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Oct 2009
    Location
    London, UK
    Posts
    382
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Unsafe JavaScript attempt to access frame with URL...

    I'm embedding a youtube vid into a webpage using jQuery. Why? Because I want valid HTML markup.

    So here's what I'm doing:
    Code:
    $(document).ready(function(){
      var youtube = $('#youtube a').attr('href').match(/http:\/\/youtu.be\/(.+)/)[1];
      $('#youtube').append('<iframe width="560" height="315" src="http://www.youtube.com/embed/' + youtube + '" frameborder="0" allowfullscreen></iframe>');
    });
    The HTML markup is as follows:
    Code:
    <div id="youtube">
      <a href="http://youtu.be/dr0tCny046Q">New Video - Not Tonight</a>
    </div>
    And I'm getting the following error message:
    Unsafe JavaScript attempt to access frame with URL http://www.heycarrianne.co.uk/ from frame with URL http://www.youtube.com/embed/dr0tCny046Q. Domains, protocols and ports must match.

    What gives? Don't really understand why this is unsafe. Not sure what to do about it.

    Cheers,
    Mike

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,189
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    If your using Google Chrome this warning will always appears as iframes are a security risk due to JavaScript injection attacks that can occur from within them. If you are however using trusted sources then this warning isn't something to really about unless your concerned about it, if you do get concerned with it you can always use the YouTube API which i believe is 100% secure.

  3. #3
    SitePoint Addict
    Join Date
    Oct 2009
    Location
    London, UK
    Posts
    382
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks Chris, I'll look into it.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •