Home >Web Front-end >HTML Tutorial >Use jquery to repair the page anchor failure problem under iframe_HTML/Xhtml_Web page production
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