Use jquery to solve the problem of page anchor invalidation under iframe _ jquery

Source: Internet
Author: User
If the iframe page does not have a scroll bar and a scroll bar appears in the parent form, the anchor mark will become invalid. js is used to determine whether the page is nested. The Application Scenario of calculating iframe in the parent form using js is: the iframe page does not have a scroll bar. If a scroll bar is displayed in the parent form, the anchor mark will become invalid because the anchor will scroll through the window based on the current window scroll bar and no scroll bar will appear after it becomes a child form, naturally, it does not scroll.

Solution: Use js to determine whether the page is nested. Use js to calculate the position of iframe in the parent form and the position of the anchor in the firame. The two are added as the scrolling of the parent form.

Problem: Get the parent form element (because of domain restrictions, all needs in the network environment (that is, http://domain.com); parent form nested multiple iframe to determine whether it is the current iframe page.

Code:

Parent form page index.html

ddddd

Window page iframe.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.