Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document.write() removes Eruda. #413

Open
Mazedotexe opened this issue Jan 25, 2024 · 3 comments
Open

document.write() removes Eruda. #413

Mazedotexe opened this issue Jan 25, 2024 · 3 comments

Comments

@Mazedotexe
Copy link

Mazedotexe commented Jan 25, 2024

This is just a silly little bug I found, not very important. But document.write() really does affect the entire document, including Eruda. You also cannot bring it back after writing. I'm sure this is an easy fix, but I could be wrong. Thanks!

@laparda14
Copy link

That is weird. The entire webpage just goes white like the white screen of death.

@feeshmaster
Copy link

feeshmaster commented Mar 29, 2024

i mean thats because that completely clears the document. if you really want it to be added back though you can do something like this to override the document.write function and make it re-add eruda after the clear:
let oldFunc = document.write; document.write = function (...args) { if (args.length === 0) { //it cant be empty or it just doesnt work so it adds a useless <i> tag if no arguments are given args = ["<i>"] } oldFunc.apply(this, args); //reload eruda let script = document.createElement("script"); script.src = "https://cdn.jsdelivr.net/npm/eruda"; document.head.append(script); script.onload = function () { eruda.init(document); }; };

i dont know why i even did this

@Mazedotexe
Copy link
Author

i mean thats because that completely clears the document. if you really want it to be added back though you can do something like this to override the document.write function and make it re-add eruda after the clear: let oldFunc = document.write; document.write = function (...args) { if (args.length === 0) { //it cant be empty or it just doesnt work so it adds a useless <i> tag if no arguments are given args = ["<i>"] } oldFunc.apply(this, args); //reload eruda let script = document.createElement("script"); script.src = "https://cdn.jsdelivr.net/npm/eruda"; document.head.append(script); script.onload = function () { eruda.init(document); }; };

i dont know why i even did this

Sure, I could. But the problem isn't necessarily that document.write specifically causes problems that I don't want; the problem is that "document" refers to the entire document, including Eruda, and this can cause problems in many ways, that being one of them. Also, I don't think anybody actually uses document.write and would care enough to use a script like the one you provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants