N
N
Nadim Zakirov2022-01-07 15:13:05
JavaScript
Nadim Zakirov, 2022-01-07 15:13:05

Why doesn't document.write work in Firefox?

When I try to rewrite the content of the page, I get an error that it is unsafe: I
SecurityError: The operation is insecure.
run the code from the content script of my own browser extension.

Can you please tell me how can I use document.write in Firefox browser? Maybe there is some tricky setting in the browser configs that disables the ban? Or some special permission for extension manifest?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nadim Zakirov, 2022-01-14
@zkrvndm

Thanks to Aetae for suggesting a solution that works in Firefox:

document.wrappedJSObject.write(''); document.close();

If you run the method from the content script in your extension even before the DOM is drawn, this will prevent the launch of site scripts, and then you can safely fill in your content on the page.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question