2014-02-10 92 views
8

我有一個非常基本的html元素,我想fadeIn()。然而,我使用require.js,所以我認爲這可能是問題的一部分。我使用jQuery 2.0.3當使用fadeIn我得到這個錯誤:jQuery 2.0.3 bug - fadeIn(),show()在firefox中破解 - SecurityError:操作不安全

SecurityError: The operation is insecure. 
chrome://firebug/content/console/commandLineExposed.js 
Line 5 

我以前從未見過這一點,我已經重置Firefox和我的電腦。

的Html

<message-box> 
     <message-info></message-info> 
     <close-box>x</close-box> 
</message-box> 

JS

$('message-Box').fadeIn(); 

我只得到這個錯誤與firefox v27。沒有其他的瀏覽器有這個問題,但我沒有任何舊版本的FF

我不求比誤差之外的任何幫助測試它...

See the error in action?並運行此命令:SD.message.showMessage('Somehow this breaks everything', 'bad');

----- 編輯 -------

那麼傷心,你需要測試這個Here我向你保證,這是SFW,它只是登錄頁。

我相信我的其他JS文件中肯定有東西存在衝突,但我還沒有發現問題。

我刪除了一個在這裏的小提琴,因爲它沒有任何幫助的問題,因爲添加我希望它的賞金儘可能有幫助。

第二個編輯

奇怪的是,在運行任何show(), hide(), fadeIn()等一個iframe時在頁面的基礎上,就在身體之前創建。我需要在代碼中思考爲什麼會發生這種情況。

第三編輯

我對這個沒有任何理由或解釋,但更新到2.1.0 jQuery的有固定我的問題。如果任何人都可以解釋的問題,那麼我很樂意給他們點:)

+2

這不是有效的HTML。 – enapupe

+2

當然是它的html5我的朋友。你上次什麼時候閱讀了規範:http://w3c.github.io/webcomponents/spec/custom/,並且讚揚那些贊成它的人。 –

+0

添加高度:100%到messageBox似乎工作。 http://jsfiddle.net/9Frn8/5/ – enapupe

回答

8

單步執行jQuery代碼,您最終會在下面找到這個內部函數。 jQuery嘗試寫入iframe文檔時會引發安全錯誤。 jQuery 2.1.0有一個確定默認節點顯示值的不同方式,所以你可以把它當作jQuery/browser組合錯誤。您可以通過粘貼以下到控制檯微創重建安全錯誤:

var iframe = jQuery("<iframe frameborder='0' width='0' height='0'/>").css("cssText", "display:block !important").appendTo(document.documentElement); 
iframe[0].contentWindow.document.write("<!doctype html><html><body>"); 

內部jQuery函數:

function css_defaultDisplay(nodeName) { 
    var doc = document, 
     display = elemdisplay[ nodeName ]; 

    if (!display) { 
     display = actualDisplay(nodeName, doc); 

     // If the simple way fails, read from inside an iframe 
     if (display === "none" || !display) { 
      // Use the already-created iframe if possible 
      iframe = (iframe || 
       jQuery("<iframe frameborder='0' width='0' height='0'/>") 
       .css("cssText", "display:block !important") 
      ).appendTo(doc.documentElement); 

      // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse 
      doc = (iframe[0].contentWindow || iframe[0].contentDocument).document; 
      doc.write("<!doctype html><html><body>"); 
      doc.close(); 

      display = actualDisplay(nodeName, doc); 
      iframe.detach(); 
     } 

     // Store the correct default display 
     elemdisplay[ nodeName ] = display; 
    } 

    return display; 
} 
2

specification自定義元素應具有「 - 」在他們的標籤,讓您的標記應該是這樣的:

<message-box> 
    <x-message><div></div></x-message> 
    <x-close>x</x-close> 
</message-box> 

更改和相應的樣式更新後,它的工作原理據我所知:http://jsfiddle.net/9Frn8/11/

+0

我會試試這個在工作版本上,而不是小提琴版本。錯誤只發生在我給的鏈接上。 –

2

看起來像這可能是由於您的CSS文件中的絕對路徑。我也看到(在控制檯中)你正在嘗試調用localhost(當然,這失敗了)。您的代碼中似乎存在一些導致Firefox停止特定進程的問題。具體來說,firefox考慮跨域。

這很可能是一個Same-Origin-Policy問題。

+0

humm有趣,我會看看這個。雖然調用這個不應該做任何Ajax調用。 $('messageBox')。show()你不會期望一個ajax調用:) –

+0

不是。但是你的CSS文件也有字體系列名稱,如:C:\ folder1 \ folder2 \ ..... – Kovo

+0

關於本地主機的非常好的一點,這是來自'livereload.js'。我會刪除它,並看看那會導致:) –