The child page accesses the parent parent page variables, functions, page elements
//变量: //在父页面中需定义为全局变量 //子页面中调用 var childFrameVar= parent.ParentVarName; //函数: parent.ParentMethodName(); //页面元素: //通过获取document对象,来对页面元素进行操作 parent.document parent.window.document
The parent page accesses the child page functions, page elements
//函数 //做出以下尝试,但alert出来的信息均为undefine FrameName.window.childMethodName(); document.getElementById('FrameId').contentWindow.childMethod(); //页面元素 FrameName.window.document document.getElementById('FrameId').contentWindow.document document.getElementById('FrameId').contentDocument
Notes
Make sure to operate after the iframe is loaded. If If the iframe starts calling methods or variables before it is loaded, an error will occur.
Try not to call page elements or functions in the child page in the parent page. Try to complete all the interactive operations in the child page.
There are two ways to determine whether the iframe has been loaded:
1. Use the onload event on the iframe
2. Use document.readyState=="complete" to determine
The above is the detailed content of Things to note when sharing iframe tags. For more information, please follow other related articles on the PHP Chinese website!