Use js to call js functions in iframe pages

Use js to call js functions in iframe pages
Recently, I have been working on thesis proposals every day. I was itching to show my skills and design the Web again. Suddenly, I ran into a problem. In the past, when I designed WEB pages, I always ran them in IE. I never considered Firefox, let alone Chrome. But now it is different. At least I think that WEB pages that are not compatible with Firefox are extremely ugly and fake. So since I had this concept, I began to pay attention to compatibility when designing pages. This time, I encountered a compatibility problem. There is a floating frame in html, <iframe>, which can embed a page in the page. It is very suitable for making a frame page, as shown in the figure below.

An HTML page is divided into two parts, the left side is the navigation bar, and the right side is the content to be displayed. The code is as follows:
The code for the left column is:
<IFRAME frameBorder=0 id=frmTitleLeft name=framLeft src="left.html" style="HEIGHT: 100%; width:180px;">
Connect to left.html
The right column is similar. For the page I made, the preview effect is as follows:

Now what kind of effect can be achieved to achieve a more practical effect? ​​Click any link and it will be displayed in the right column. Obviously, it needs to be implemented through js. I will not say much about the original incompatible method. Please remember the following implementation steps:
1. First, get the right column iframe object
var frames=document.getElementById("frameid"); //frameid is the id name of the iframe in the right column
2. Reset its src value
frames.src=pageurl; //pageurl is the destination page to be displayed, so the page jump is realized

But there is one more thing. If you want to call a function in it, it is not so simple. For example, there is a function right() in the right column. I want to call the right() function in the link in the left column. How can I achieve it?

1. First, leftframe is embedded in the container page index.html, so you need to return to the index level and get the rightframe object
var frames=window.parent.window.document.getElementById("frameid");

2. To be able to execute the functions in its page, you must obtain the window object. There is an important object contentWindow here. After obtaining this object, you can execute the functions in it, such as
frames.contentWindow.right();

The above code is compatible with IE6, Firefox3, and Chrome2.0, and has passed the test successfully. I haven't tried IE7, but it should be fine.

<<:  jQuery canvas generates a poster with a QR code

>>:  Use Smart CSS to apply styles based on the user's scroll position

Recommend

Summary of Linux system user management commands

User and Group Management 1. Basic concepts of us...

Example of using CSS3 to create Pikachu animated wallpaper

text OK, next it’s time to show the renderings. O...

Detailed explanation of display modes in CSS tags

Label display mode (important) div and span tags ...

5 Reasons Why Responsive Web Design Isn’t Worth It

This article is from Tom Ewer's Managewp blog,...

VMware installation of Ubuntu 20.04 operating system tutorial diagram

Memo: Just experience it. Record: NO.209 This exa...

Summary of four ways to introduce CSS (sharing)

1. Inline reference: used directly on the label, ...

Nginx compiled nginx - add new module

1. View existing modules /usr/local/nginx/sbin/ng...

Pure CSS to achieve the list pull-down effect in the page

You may often see the following effect: That’s ri...

Docker Compose network settings explained

Basic Concepts By default, Compose creates a netw...

Summary of knowledge points on using calculated properties in Vue

Computed properties Sometimes we put too much log...

Summary of 10 must-see JavaScript interview questions (recommended)

1.This points to 1. Who calls whom? example: func...

Detailed explanation of the use of HTML header tags

HTML consists of two parts: head and body ** The ...

MySQL data backup and restore sample code

1. Data backup 1. Use mysqldump command to back u...

js native waterfall flow plug-in production

This article shares the specific code of the js n...

TypeScript namespace explanation

Table of contents 1. Definition and Use 1.1 Defin...