2013-05-28 51 views
12

不允許當我嘗試運行在的jsfiddle我的JavaScript文件中的一個,我收到以下錯誤信息:錯誤信息:文件撰寫中的jsfiddle

文件撰寫中的jsfiddle環境不允許,可能會打破你的小提琴。

如何解決此問題?

注:當我使用外部資源時,它工作正常。但我想使用腳本的JavaScript面板。

回答

0

你的代碼中有document.write,這打破了結果面板和awesome的初始化。從您的代碼&

刪除document.write它開始與您的代碼再次

+0

難道這意味着刪除所有文件撰寫的代碼? – Nishantha

+1

^^^是的。 jsfiddle – CuriousMind

8

它不是任何問題的工作。它與jsfiddle相關,它不允許運行那些代碼爲document.write

作爲替代,你可以使用

console.log(x); 

曾經你有一個

document.write(x); 

在哪裏以及在鉻檢查器或Firebug的控制檯來驗證結果檢查。

如果你更關心爲什麼document.write被jsfiddle阻止,下面的So帖子可能有助於更好的理解。

Why am i receiving this jsfiddle error, document.write can be a form of eval

Why is document.write considered a "bad practice"?

+1

不支持'document.write'問題。但輸出不會來。無論如何謝謝.. – Nishantha

4

在測試腳本,你可以這樣做:

document.write = function(txt) 
{ 
    console.log(txt); 
} 
document.write("hey"); 

你滿意的時候,只需要將這部分分離出來

1

您可以嘗試使用 document.body.innerHtml = "Hello";

+1

不適用於jsFiddle – Divick