Home >Web Front-end >HTML Tutorial >Use jquery to repair the page anchor failure problem under iframe_HTML/Xhtml_Web page production

Use jquery to repair the page anchor failure problem under iframe_HTML/Xhtml_Web page production

WBOY
WBOYOriginal
2016-05-16 16:37:041267browse

The application scenario is: the iframe page does not have scroll bars. If a scroll bar appears in the parent form, the anchor mark will become invalid, because the anchor point scrolls the window based on the current window scroll bar. After it becomes a child form, there is no scroll bar. Naturally it won't scroll.

The solution is: use js to determine whether the page is nested, use js to calculate the position of the iframe in the parent form, the position of the anchor point in the firame, and add the two to become the scrolling of the parent form.

Encountered a problem: Get the parent form element (because of domain restrictions, all need to be in the network environment (i.e. http://domain.com)); the parent form nests multiple iframes, judge Whether it is the current iframe page.

Code:

Parent form page index.html

Copy code
The code is as follows:









dd
ddd




Subform page iframe.html

Copy code
The code is as follows:










a
b
c
d



D



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