Home > Web Front-end > HTML Tutorial > How to add js function to iframe in page_html/css_WEB-ITnose

How to add js function to iframe in page_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:57:06
Original
1351 people have browsed it

As the title says, I used an iframe to create an input box on the jsp page, but the iframe does not seem to support the onclick function. How can I add a function to this iframe to achieve the onclick effect? I hope God will give you some advice, thank you very much! Waiting online


Reply to the discussion (solution)

If it is not cross-domain, you can access the page window object in the ifram through iframe.contentWindow, register its body or The click event of the document is enough;
If it crosses the domain, it will be difficult to do.

If it does not cross the domain, you can access the page window object in the ifram through iframe.contentWindow and register its body or document. Just click on the event;
If it is cross-domain, it will be difficult to do it

I would like to ask, what is cross-domain? ? Can you give an example?

I don’t understand why you want to add a click event to the iframe. Cross-domain means responding to requests from different sites. Generally speaking, our web programs switch between different pages under one site, and these pages are all under the same server. If we talk about cross-domain, for example, if you want to embed a weather function in an iframe, but the weather data comes from the interface of an official data website of a certain national department, then this is cross-domain.


If it is not cross-domain, you can access the page window object in the ifram through iframe.contentWindow, and register the click event of its body or document;
If it is cross-domain, It’s very difficult

I would like to ask, what is cross-domain? ? Can you give an example?
Domain name port protocol, you can simply understand that if you use a relative path, it will not cross domain; if you use an absolute path (such as http://xxx.htm), it will cross domain

I don't understand why you want to add a click event to the iframe. Cross-domain means responding to requests from different sites. Generally speaking, our web programs switch between different pages under one site, and these pages are all under the same server. If we talk about cross-domain, for example, if you want to embed a weather function in an iframe, but the weather data comes from the interface of an official data website of a certain national department, then this is cross-domain.


This problem has been around for a long time. It happened when I was working on a project before. It seems to have been solved. Points are given. Thanks for the help!
Related labels:
source:php.cn
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