Home > Web Front-end > JS Tutorial > Jquery method to obtain content under iframe_jquery

Jquery method to obtain content under iframe_jquery

WBOY
Release: 2016-05-16 17:14:27
Original
788 people have browsed it
Copy code The code is as follows:

document.all('Iframe1').contentWindow.document.getElementById( "deptName").width;

$(window.parent.Iframe1.document.body).find('#deptName').width();

Cross-domain call IFRAME will encounter access denial. I found an untested solution on the Internet
After checking the information, I found that by default, the browser prohibits cross-domain access of scripts unless there is a necessary access trust relationship between these domains.

It’s easier to solve if you find the problem. You can lower the security level of the browser, but this is undoubtedly detrimental to users.

So we need to add a piece of js on the page
Copy the code The code is as follows:

try
{
document.domain = "xxx.net";
}
catch(e)
{
}

Manual Set the domain names of the child page and the parent page to the same one and the problem will be solved.
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