Home > Web Front-end > JS Tutorial > Disable all js scripts on iframe pages such as alerts and pop-up windows_javascript skills

Disable all js scripts on iframe pages such as alerts and pop-up windows_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 16:37:34
Original
1292 people have browsed it

I encountered a problem when making a small software today, that is, I need to put an iframe in a page to preview the website, but the previewed website contains a lot of js scripts, such as pop-up windows and prompt boxes. The most disgusting thing is I kept setting it as homepage and adding it to favorites. I thought there should be a way to ban scripts in iframes, so I searched on Baidu and found a lot of new continents. So I solved the problem and recorded it for future inquiries and for everyone’s reference:

<iframe src="fillseo.html"></iframe>
Copy after login

There is a js script in fillseo.html, which contains alerts and pop-up windows. It’s disgusting, how can I disable them?
And this fillseo.html is a file in a different domain.

After reviewing countless relevant information, I found that the following code can completely solve this problem:

Program code one:

<noscript><iframe src=fillseo.html></iframe></noscript>
Copy after login

or

Program code two:

<iframe src="fillseo.htm" width="200" height="200" id="Pcyear"></iframe>
<script>
var fillseo_window=window.frames["Pcyear"];
fillseo_window.window.alert=function(){
alert("弹弹弹!");
//也可以写你想写的东东
};
</script>
Copy after login
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template