Jslfl【软件开发技术笔记】

iframe操作记要

使用UUR框架时,主页上iframe结构如下

index
|-My97DatePicker,没使用这个日历控件时没有这个iframe
|-frameleft左侧菜单
|-frameright右侧内容

当在frameright中有UUR框架弹出窗口时,会在index加一个DIV,里面会有个iframe,结构如下
index
|-My97DatePicker,没使用这个日历控件时没有这个iframe
|-frameleft左侧菜单
|-frameright右侧内容
|-iframe 弹出窗口

所以在弹出窗口中要控制父窗口(frameright)时,可以如下
top.document.frames[“frameright”]或下标来得到frameright的对象(测试过)
或者 top.frameright (UUR中的说明)

如果frameright下再有iframe,并且在iframe中调用UUR弹出窗口,则结构为
index
|-My97DatePicker,没使用这个日历控件时没有这个iframe
|-frameleft左侧菜单
|-frameright右侧内容
|-iframe(user frame)
|-iframe 弹出窗口
在弹出窗口中要控制父窗口(user frmae)时,如下
top.document.frames[“frameright”].document.frames[“user frame”]

document.frames返回iframe数组

实例:top.document.frames[“frmright”].document.frames[“jfmx”].location.href = “”

UUR中调用弹窗
diag.innerFrame.contentWindow.document

uur中调用弹窗青元素
diag.innerFrame.contentWindow.document.getElementById(‘a’).value;
diag.innerFrame.contentWindow.valaSubmit();

 

iframe内调用父窗口方法
parent.window.fun(vObj);
调用iframe内元素
window.onload中
var iobj = document.getElementById(“rkmx1list”).contentWindow;
alert(iobj.document.getElementById(“xsjesum”));

jquery调用iframe内元素
得到iframe中文本框值
$(window.frames[“iframename”].document).find(“#xsjesum”).val()
iframe内调用父窗口元素
$(window.parent.document).find(“input[@type=’radio’]”).attr(“checked”,”true”)

设置当前框架(iframe,当前iframe.id=’mainframe’)的属性
$(window.parent.document).find(“#mainframe”).attr(“scrolling”,”no”);//先得到父窗口的文档对象,再得到当前框架

当iframe的src有默认值时,再通过JS动态刷新时(url不变),在JS刷新的url查询字符串中加入
Math.floor(Math.random() * 100)

如原URL应该是;/admin/addrkmx_list.do?flag=1
则JS处应该写:/admin/addrkmx_list.do?” +Math.floor(Math.random() * 100) + “&flag=1”

top、parent、frame
top:
该变量永远指分割窗口最高层次的浏览器窗口。如果计划从分割窗口的最高层次开始执行命令,就可以用top变量。
parent:
该变量指的是包含当前分割窗口的父窗口。如果在一个窗口内有分割窗口,而在其中一个分割窗口中又包含着分割窗口,则第2层的分割窗口可以用parent变量引用包含它的父分割窗口。
附:Window对象、Parent对象、Frame对象、Document对象和Form对象的阶层关系
Windwo对象→Parent对象→Frame对象→Document对象→Form对象,如下:
parent.frame1.document.forms[0].elements[0].value;
在JS中:window.location(window.location.href)和window.top.location(window.top.location.href)是一样的意思
可以通过top来调用任何一个frame,因为top指的是最外层的frameset,可以调用它里面的任何一个子元素frame。如:top.outterFrame1.location和top.innerFrame2.location等。
parent指的是当前窗口(frame)的父窗口(frameset)可以调用它里面的任何一个子元素frame。如:parent.innerFrame1.location和parent.innerFrame2.location等。

, ,

Comments are currently closed.