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?


<div class="yturl"></div>


    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=\""+regexyoutubeurl[2]+"\" frameborder=\"0\" allowfullscreen></iframe>");




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:

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 produces the same error message in the latest Firefox version (both in the Firebug console, or the Firefox Error Console window).

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 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 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.


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.


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="" frameborder="0" allowfullscreen></iframe>

HTML version only demo

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


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


Ignore that error, it's not related to your code. Just a browser bug.


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.