Javascript accesses frame, IFRAME framework, and href targeting
Source: Internet
Author: User
I. frame1. the reference from the parent framework to the Child Framework knows the above principle, and it is very easy to reference the child framework from the parent framework, that is, window. frames ["framename. If you want to reference the sub-framework in the sub-framework, the referenced framework is actually the nature of the window object, which can be implemented as follows: window. frames ["framename"]. frames ["framename2"]; in this way, the second-level sub-framework is referenced, and so on. 2. references from the Child Framework to the parent framework each window object has a parent attribute, indicating its parent framework. If the framework is already a top-level framework, window. Parent also indicates the framework itself. 3. the reference between the sibling frameworks if the two frameworks are the same as the Child frameworks of the same framework and they are called the sibling frameworks, mutual reference can be achieved through the parent framework. For example, a page includes two child frameworks: <frameset rows = "50%, 50% "> <frame src =" 1.html "name =" frame1 "/> <frame src =" 2.html "name =" frame2 "/> </frameset> can be used in frame1. use the following statement to reference frame2: self. parent. frames ["frame2"]; 4. the frameworks of different levels reference each other. When the hierarchy is different, you only need to know the hierarchy of the framework and the hierarchy and name of the other framework, and use the window object properties referenced by the Framework to easily implement mutual access, such as self. parent. frames ["childname"]. frames ["targetframename"]; 5. the reference to the top-level framework is similar to the parent attribute. The window object also has a top attribute. It indicates the reference to the top-level framework, which can be used to determine whether a framework itself is a top-level framework, for example: // determine whether the framework is a top-level framework if (Self = top) {// dosomething} the reference to the framework on the loading page of the framework is the reference to the window object. The location attribute of the window object can be used to change the navigation of the framework, for example, window. frames [0]. location = "1.html"; before introducing the techniques for referencing JavaScript variables and functions in other frameworks, let's take a look at the following: Code : <Script language = "JavaScript" type = "text/JavaScript"> <! -- Function Hello () {alert ("Hello, Ajax! ");} Window. hello (); // --> </SCRIPT> 2. iframeshould use framesnumber groups, and .doc ument. all. <IFRAME id = myiframe src = "about: <input type = checkbox name = mycheckbox value = mycheckbox>"> </iframe> <input type = button onclick = "alert(document.frames.myiframe.doc ument. all. mycheckbox. checked) "> 3. the onclick event of the href link is executed first, followed by the action under the href attribute (page Jump, or Javascript pseudo link). Assume that both href and onclick exist in the link, to disable the action under the href attribute, onclick must return a value of false. Do not believe it. You can comment out the return false in the gogoogle function. If the page is too long with a scroll bar and you want to perform operations through the linked onclick event. Set its href attribute to javascript: void (0); instead of #, which can prevent unnecessary page beats; if you call a function with a returned value in the href attribute of the link, the content on the current page will be replaced by the returned value of this function. It will be different when you hold down the Shift key. The problem I encountered today is that the parentnode cannot be accessed in the form of href in ie6.0. Try not to use JavaScript: the protocol is used as the href attribute of A. This will not only trigger the window. onbeforeunload event unnecessary, but also stop playing GIF animated images in IE. For example, <a href = "javascript: void (0)" onclick = "linkchangepwd ()"> Change Password </a>
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.