Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace url from youtube to embed code - Error: Permission denied to access property 'toString'

I have this code and this error in FireBug:

Error: Permission denied to access property 'toString'

How can i fix this error?

HTML:

<div class="yturl">http://www.youtube.com/watch?v=UNMLEZrukRU</div>

JS:

$("div.yturl").each(function(){
    var regex = /(\?v=|\&v=|\/\d\/|\/embed\/|\/v\/|\.be\/)([a-zA-Z0-9\-\_]+)/;
    var youtubeurl = $(this).text();
    var regexyoutubeurl = youtubeurl.match(regex);
    if (regexyoutubeurl) 
    {
         $(this).html("<iframe width=\"390\" height=\"315\" src=\"http://www.youtube.com/embed/"+regexyoutubeurl[2]+"\" frameborder=\"0\" allowfullscreen></iframe>");
    }
});

DEMO: http://jsfiddle.net/9e48p/

like image 674
JohnMalcom Avatar asked Oct 27 '12 13:10

JohnMalcom


4 Answers

The error can either be fixed by Adobe's Flash Player team, or by the Google engineers - you should just ignore it for now. It's connected to Flash Player security settings and the SWF file embedded into the Youtube page. The problem has been reported in the past by IBM, and there is a Mozilla Bugzilla entry as well.

When I deactivate Flash Player in Firefox 16.0.2, the error message disappears. Check comment #37: https://bugzilla.mozilla.org/show_bug.cgi?id=434522#c37

For what it's worth, I'm seeing this bug happen when any flash file, even ones that have NO actionscript calls (ExternalInterface, etc) in them at all, is loaded into an iframe on a page where the page domain and the iframe domain are different. This means that the iframe problem is caused when there is in fact a cross-domain situation in place. However, it's not totally clear if there's really actually attempting to be a cross-domain call that should be prevented and error'd out.

Because it's nothing that the flash SWF itself is trying to call to do "Location.toString", and it's nothing about the javascript on the page doing it, the only choice is that there's something about the flash plugin itself (9.0.124 is what I'm testing with) that's trying to make that call up to the parent/top window to do Location.toString().

While the bug is marked as resolved, the test case attached https://bug434522.bugzilla.mozilla.org/attachment.cgi?id=321956 produces the same error message in the latest Firefox version (both in the Firebug console, or the Firefox Error Console window).

Update:
The bug has been filed with Adobe as well in the old bug database: FP-561 "Location.toString" uncaught (security) exception caused by improper Flash plugin behavior (you need an account to see the bug details). The last comment there when the bug was closed:

Tested with the latest Flash Player 10.3.181.34 on Firefox 4 and 5, no such exception was thrown. So the bug may have been fixed, right? If you still meet this issue, please file a bug in our new bug system https://bugbase.adobe.com/ and put a link in the new bug to this original JIRA report. We are happy to follow up your report in the new bug system.

like image 54
raju-bitter Avatar answered Nov 20 '22 06:11

raju-bitter


Don't ignore this error just because its not related directly to your code.

It seems to occur when your embed is initialy hidden.

Just add ?html5=1 to your embed url. IE8 will still take flash version. or load your video with the Youtube api.

like image 27
air Avatar answered Nov 20 '22 07:11

air


Something is likely wrong with your Iframe url constructor. The error is being thrown in a youtube script that loads in the Iframe. The same error gets thrown with a harcoded html Iframe that isn't dynamically added with your script

<iframe width="390" height="315" src="http://www.youtube.com/embed/UNMLEZrukRU" frameborder="0" allowfullscreen></iframe>

HTML version only demo http://jsfiddle.net/Lgt5f/

Double check the url isn't missing a parameter , otherwise I would check youtube support resources

like image 2
charlietfl Avatar answered Nov 20 '22 08:11

charlietfl


That issue can be caused by an extension that isn't working properly.

Start Firefox in Troubleshoot Firefox issues using Safe Mode to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance/Themes).

like image 1
NullPoiиteя Avatar answered Nov 20 '22 08:11

NullPoiиteя