Viii. Framework
Example. Let's assume that your site uses a framework that provides some functional navigation (just like this site Www.javascripter.net/faq). Suppose your top-level frameset (frameset) is in the file /index.hm . If a user accesses some pages that are not in the frame, what should be done? (This can happen if the user uses a search.) For this type of user, you may want to display a hyperlink to the top-level frameset-only when the page is not in the frame.
if (self.location!=top.location) top.location=self.location;
However, use this tip sparingly-especially if your own site uses frames.
Translator:
There are two things about this:
1. For standalone pages, you can use the above method
2. If the page is also in the frame, You can determine whether the name of the frame is the same as the preset:
if (window.name!= "DD") top.location=self.location;
3. Update two frames simultaneously (updating tow frames at a time?)
Q : Can I update two (or more) frames at the same time?
A : OK. The easiest way to update several frames at the same time is to use JavaScript functions to load new pages into the frame that is about to be updated. For example, if you have two frames, left, and right, then the same function that updates both frames is
function Updatebothframes () {
Top.left.location= "newpage1.htm";
Top.right.location= "newpage2.htm";
This function can be invoked when the user presses a button or clicks a hyperlink. The following example shows the HTML code to create buttons and hyperlinks that call this function:
<a href= "Javascript:updatebothframes ()" >click here</a> <input Type=button value= "Press Me" onclick= "Updatebothframes ()" >