Is there any way to replace document.write
of an external script that I can't edit?
<div class="mydiv">
<script type="text/javascript" src="https://www.formstack.com/forms/js.php?3349003-8L4WS0Z6Xi"></script>
</div>
I tried the below code to replace it but it just messed up all the things
document.write=function(s){
var scripts = document.getElementsByTagName('script');
var lastScript = scripts[scripts.length-1];
lastScript.insertAdjacentHTML("beforebegin", s);
}```
Not sure why you want to overwrite it, maybe to improve performance with append?
document.write = function(s) {
document.body.append(s)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.