2012-10-27 8 views
43

Ho questo codice e questo errore in FireBug:Sostituire URL da youtube a incorporare il codice - Errore: Autorizzazione negata per accedere alla proprietà 'toString'

Error: Permission denied to access property 'toString'

come posso risolvere questo errore?

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/

+0

Quali versioni di Firefox e Firebug utilizzi? –

+0

FireBug 1.10.5., FF 16.0.2 – JohnMalcom

+1

Quando apro il file demo in Chrome, la console JS in Chrome mostra anche un messaggio di errore: "Tentativo JavaScript non sicuro di accedere al frame con URL http://jsfiddle.net/ 9e48p/da frame con URL http://www.youtube.com/embed/UNMLEZrukRU. Domini, protocolli e porte devono corrispondere. " –

risposta

67

L'errore può essere corretto dal team di Adobe Flash Player o dai tecnici di Google. Dovresti semplicemente ignorarlo per ora. È collegato alle impostazioni di sicurezza di Flash Player e al file SWF incorporato nella pagina Youtube. Il problema è stato reported in the past by IBM e c'è anche uno Mozilla Bugzilla entry.

Quando disattivo Flash Player in Firefox 16.0.2, il messaggio di errore scompare. Controllare commento # 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().

Mentre il bug è contrassegnato come risolto, il banco di prova fissato https://bug434522.bugzilla.mozilla.org/attachment.cgi?id=321956 produce lo stesso messaggio di errore nella versione più recente di Firefox (sia nella console Firebug, o la finestra Console di Firefox Errore) .

Aggiornamento:
Il bug è stato depositato presso Adobe, nel vecchio database dei bug: FP-561 "Location.toString" uncaught (security) exception caused by improper Flash plugin behavior (è necessario un account per vedere i dettagli di bug). L'ultimo commento lì quando il bug è stato chiuso:

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.

+5

Ciò spiegherebbe perché non è visualizzato alcun numero di riga per l'errore JavaScript, se il problema è causato da Flash Player. –

+1

Le date in bugzilla sono davvero confuse. È stato segnalato nel 2008 e modificato per l'ultima volta nel 2009. Lo stato del bug è stato risolto e non ci sono commenti sotto questo bug da qualche tempo. – Foreever

+2

Il biglietto BugZilla è stato riaperto sotto due nuovi biglietti: [# 385676] (https://bugzilla.mozilla.org/show_bug.cgi?id=385676) e [# 1015700] (https://bugzilla.mozilla.org) /show_bug.cgi?id=1015700) Chiunque guardi il vecchio link del biglietto vedrà che è chiuso/"corretto", ma scorrere verso il basso nei commenti per ottenere maggiori informazioni a riguardo. – Sean

1

Questo problema può essere causato da un prolungamento che non funziona correttamente.

Avvia Firefox in Risolvi i problemi di Firefox utilizzando la Modalità provvisoria per verificare se una delle estensioni o se l'accelerazione hardware sta causando il problema (passa al tema DEFAULT: Firefox/Strumenti> Componenti aggiuntivi> Aspetto/Temi).

2

È probabile che qualcosa non funzioni correttamente con il tuo costruttore di URL Iframe. L'errore viene generato in uno script di youtube che viene caricato nell'Iframe. Lo stesso errore si butta con un html Iframe harcoded che non viene aggiunto in modo dinamico con lo script

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

versione HTML solo demo http://jsfiddle.net/Lgt5f/

Assicurati l'URL non manca un parametro, altrimenti avrei controllare risorse di supporto per youtube

0

Ignora tale errore, non è collegato con il vostro codice. Solo un bug del browser.

+1

Ehm, no, non è solo un bug del browser. – ggdx

48

Non ignorare questo errore solo perché non è correlato direttamente al codice.

Sembra che si verifichi quando il tuo embed è inizialmente nascosto.

Basta aggiungere ?html5=1 all'URL di incorporamento. IE8 continuerà a prendere la versione flash. o carica il tuo video con l'API di Youtube.

+0

Questo ha risolto il mio problema. Grazie – DreamWave

+1

Lei signore ha ragione. Grazie per l'aiuto. –

+1

Eccezionale. Wtf erano tutti gli ingegneri Adobe e Reported by IBM BS pubblicati nella risposta "accettata" sopra? – ggdx

Problemi correlati