The application scenario is: the iframe page has no scroll bars, and the scroll bar appears in the parent form, and the anchor mark will fail, because the anchor point scrolls the window according to the current window scroll bar. After becoming a child form, there will be no scroll bars, so it will naturally not 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 fiber, and the two add up to become the scroll of the parent form.
Encountering problems: Get the parent form element (because of domain restrictions, all need to be located in the network environment (i.e. http://domain.com)); the parent form nests multiple iframes to determine whether it is the current iframe page.
Code:
Parent form page index.html
Copy the code