Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
204 views
in Technique[技术] by (71.8m points)

javascript - 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/

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...