Reputation: 6695
When I try to run one of my JavaScript files on JSFiddle, I get the following error message:
document.write is disallowed in JSFiddle environment and might break your fiddle.
How do I fix this issue?
Note: When I use external resources, it works fine. But I want to use the JavaScript panel for scripts.
Upvotes: 12
Views: 9986
Reputation: 3188
Here's one alternative: http://jsfiddle.net/skibulk/erh7m9og/1/
document.write = function (str) {
document.body.insertAdjacentHTML("beforeend", str);
}
document.write("¡hola mundo");
Upvotes: 11
Reputation: 11805
While testing the script, you could do this:
document.write = function(txt)
{
console.log(txt);
}
document.write("hey");
And when you are satisfied, just take that part out
Upvotes: 4
Reputation: 27845
its not any issue with your code. Its related to jsfiddle that it doesnt allow to run those code having document.write
.
As an alternative you could use
console.log(x);
where ever you are having a
document.write(x);
and check up in the chrome inspector or firebug console for verifying result.
If you are more concerned about why document.write
is blocked by jsfiddle, the below So posts may help to get a better understanding.
Why am i receiving this jsfiddle error, document.write can be a form of eval
Why is document.write considered a "bad practice"?
Upvotes: 7
Reputation: 34155
You have document.write
in your code, this breaks the result panel and the initialization of awesome.
Remove document.write
from your code & it start working again
Upvotes: 0