Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of nesting iframe tags

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article editor for you a detailed introduction of "how to solve the iframe tag nesting problem", the content is detailed, the steps are clear, the details are handled properly, I hope this "how to solve the iframe tag nesting problem" article can help you solve your doubts, the following follow the editor's ideas slowly in-depth, together to learn new knowledge.

Problem description

When we use easyui as the background management system, we will use tree components to implement the tree menu. Each time we click on the corresponding menu, we will determine whether it is a first-level menu based on whether there is a url and whether it already exists:

/ / determine whether if ($("# tabs"). Tabs ("exists", node.text) exists on the node according to its name. {/ / if so, select $("# tabs") .tabs ("select", node.text);}

If not, we will nest an iframe tag to open a corresponding html window:

$("# tabs") .tabs ("add", {/ / title is the name of the current node title:node.text, / / there is no border border:false, / / whether the close button closable:true is displayed / / nested iframe tags content: ""})

What kind of problem is there at this time? In such a case, when we open the background management page in both An and B tabs in the same browser, and then we log out on page A, click "employee Management" on page A. then you should refresh globally and return to the login page.

But at this time, because we nest iframe, when we click on employee Management, the request normally sent is / employee/index, but because it is already logout, the current user is not authenticated:

Content: ""

So the url address of the iframe form here becomes login.jsp, which becomes an iframe nesting problem.

Solution idea

In our html, every open form has a window object, for example, as shown in the figure above, if you stand from the point of view of the inner form, the outer form is actually the parent form of the inner form (if you open many nesting, then the outermost form is top), if you want to get the outer form is also very simple, that is, window.parent.

At this point, if we want to open the I form that is not the outermost form, we just need to assign the outermost form object to the current form:

/ / if the current form is not the outermost form if (window! = top) {/ / then assign the address of the outermost form to the current form top.location.href = _ window.location.href } after reading this, the article "how to solve the problem of nesting iframe tags" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about related articles, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report