当前位置: 技术问答>java相关
送分了 javascrip菜鸟问题
来源: 互联网 发布时间:2015-08-11
本文导语: 在本地网页文件的弹出窗口中我可以控制其中控件的状态,但是到了internet上好像就不行了,各位能告诉我是怎么回事吗,如何实现这种控制 我的意思是在本地打开一个网页文件,然后在其中的按钮事件中弹出一个...
在本地网页文件的弹出窗口中我可以控制其中控件的状态,但是到了internet上好像就不行了,各位能告诉我是怎么回事吗,如何实现这种控制
我的意思是在本地打开一个网页文件,然后在其中的按钮事件中弹出一个窗口,然后前者对后者进行控制
我的意思是在本地打开一个网页文件,然后在其中的按钮事件中弹出一个窗口,然后前者对后者进行控制
|
这是因为从 parent_window 弹出一个窗口 new_window 后,焦点自动就转移到了 new_window, 所以这时你应该在 new_window 中调用 parent_window, 然后引用 parent_window的方法对 new_window进行控制。
在 new_window 中调用 parent_window的方法是:
window.opener 或window.parent
假如控制方法是control(), 那么可以写成:
window.opener.control() 或 window.parent.control()
以下是window对象的属性和方法参考:
Properties
.defaultStatus Reflects the default message displayed in the window's status bar
.frames An array reflecting all the frames in a window
.length Reflects the number of frames in a parent window
.name Reflects the windowName argument
.parent Refers to a window containing a tags
.self Refers to the current window
.status Specifies message to display in the window's status bar
.top Refers to the top-most Navigator window
.window Refers to the current window
.document Refers to the document on display within the window
.frame Refers to an independently-scollable frame created with a tag
.location Contains information on the URL of the document displayed in the window
Methods
.alert("msg") Displays a JavaScript alert message box with msg and OK button
.close() Closes the window
confirm("msg") Displays a JavaScript confirm message box with msg and OK and Cancel buttons
.open("URL", "windowName", ["windowFeatures"]) Opens a window displaying URL with windowName as target name and optional windowFeatures
prompt("msg",["default"]) Displays a JavaScript prompt box with msg and optional default text
timerID = setTimeout(exp,msec) Delays execution of expression msec milliseconds
clearTimeout(timerid) Cancels timerid created by setTimeOut()
在 new_window 中调用 parent_window的方法是:
window.opener 或window.parent
假如控制方法是control(), 那么可以写成:
window.opener.control() 或 window.parent.control()
以下是window对象的属性和方法参考:
Properties
.defaultStatus Reflects the default message displayed in the window's status bar
.frames An array reflecting all the frames in a window
.length Reflects the number of frames in a parent window
.name Reflects the windowName argument
.parent Refers to a window containing a tags
.self Refers to the current window
.status Specifies message to display in the window's status bar
.top Refers to the top-most Navigator window
.window Refers to the current window
.document Refers to the document on display within the window
.frame Refers to an independently-scollable frame created with a tag
.location Contains information on the URL of the document displayed in the window
Methods
.alert("msg") Displays a JavaScript alert message box with msg and OK button
.close() Closes the window
confirm("msg") Displays a JavaScript confirm message box with msg and OK and Cancel buttons
.open("URL", "windowName", ["windowFeatures"]) Opens a window displaying URL with windowName as target name and optional windowFeatures
prompt("msg",["default"]) Displays a JavaScript prompt box with msg and optional default text
timerID = setTimeout(exp,msec) Delays execution of expression msec milliseconds
clearTimeout(timerid) Cancels timerid created by setTimeOut()
|
因为你没法对internet上的htm进行编程控制呀。
|
比如:a弹出b
bwindow_nm=window.open(YourURL,"window_nm");
a内控制b;bwindow_nm.YourControl_In_B;
b内控制a:window.opener.YourControl_In_A;
bwindow_nm=window.open(YourURL,"window_nm");
a内控制b;bwindow_nm.YourControl_In_B;
b内控制a:window.opener.YourControl_In_A;