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

May 16, 2016 pm 04:37 PM
alert iframe js script Pop-ups

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
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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How do I crop an IFrame in HTML? How do I crop an IFrame in HTML? Aug 29, 2023 pm 04:33 PM

How do I crop an IFrame in HTML?

What should I do if there are no pop-up reminders for calendar events in Win10? How to recover if calendar event reminders are gone in Win10 What should I do if there are no pop-up reminders for calendar events in Win10? How to recover if calendar event reminders are gone in Win10 Jun 09, 2024 pm 02:52 PM

What should I do if there are no pop-up reminders for calendar events in Win10? How to recover if calendar event reminders are gone in Win10

What does data-id in iframe mean? What does data-id in iframe mean? Aug 28, 2023 pm 02:25 PM

What does data-id in iframe mean?

Why does iframe load slowly? Why does iframe load slowly? Aug 24, 2023 pm 05:51 PM

Why does iframe load slowly?

Edge browser js script disabling method Edge browser js script disabling method Jan 07, 2024 am 11:17 AM

Edge browser js script disabling method

How to use Vue to implement pop-up window effects How to use Vue to implement pop-up window effects Sep 22, 2023 am 09:40 AM

How to use Vue to implement pop-up window effects

What technology can replace iframe What technology can replace iframe Aug 24, 2023 pm 01:53 PM

What technology can replace iframe

What are the loading events of iframe? What are the loading events of iframe? Aug 28, 2023 pm 01:55 PM

What are the loading events of iframe?

See all articles