Disable all js scripts for iframe pages such as alerts and pop up Windows

  • 2020-03-30 03:52:15
  • OfStack

Today to do a small software encountered a problem, is in a page need to put an iframe framework to preview web site, but the preview this web site contains a lot of js script, such as pop-up window, prompt box, the worst thing is always set to the home page and add collection, I think there should be a way to ban the inside of the iframe script, so baidu, also found a lot of the new world, and solved the problem, record, convenient later inquiry, also for everyone easy reference:


<iframe src="fillseo.html"></iframe>

Fillseo.html has a js script in it with an alert and a popup window, which is pretty darn, how do you disable them?
And this fillseo.html is a file for a different domain.

After looking up numerous related materials, I found the following code, which can completely solve this problem:

Program code 1:


<noscript><iframe src=fillseo.html></iframe></noscript>

or

Program code 2:


<iframe src="fillseo.htm" width="200" height="200" id="Pcyear"></iframe>
<script>
var fillseo_window=window.frames["Pcyear"];
fillseo_window.window.alert=function(){
alert(" Play to play! ");
//You can write whatever you want
};
</script>

Related articles: