从弹出窗口调用主窗口
Call main window from the pop up window
我有一个弹出窗口,在弹出窗口中做了一些事情后,我想返回到主窗口。现在,应该出现在主窗口上的表单出现在我的弹出窗口中。
function checkForm() {
//check all necessary things
var varAmount =....; //which will get after process insides javascript
window.location = 'myaction.action?amount='+varAmount ;
}
<form name="frmUpload" target="main">...
<input type="button" class="button" value="Save" onclick="checkForm();"/>
</form>
我也想将Amount值传递给我的操作,并返回到主窗口(并在处理完成后关闭弹出窗口并调用myaction.actin)。
虽然我调用target="main"
,但它不会关闭弹出窗口并返回到主窗口。
如果您想将表单定位到主窗口,您需要在主窗口中的脚本中命名主窗口:
window.name="main";
然后将按钮更改为提交,或者删除javascript,或者将检查移动到onsubmit
function checkForm() {
//check all necessary things
var varAmount =....; //which will get after process insides javascript
if (...) return false; // cancel submit
return true; // allow submit
}
<form name="frmUpload" target="main" onsubmit="return checkForm(this)">...
<input type="submit" class="button" value="Save" />
</form>
如果您需要javascript和按钮所在的位置,则需要将其更改为
function checkForm() {
//check all necessary things
var varAmount =....; //which will get after process insides javascript
window.opener.location = 'myaction.action?amount='+varAmount
// OR using the name of the opener window
//window.open('myaction.action?amount='+varAmount,"main");
}
相关文章:
- 从父窗口调用iframe函数
- 从另一个窗口调用 iframe
- 为什么从子窗口调用时父窗口的 OnChange 事件文本框不起作用
- 在 Javascript 中,如果作为子窗口调用,则使用 focus() 设置的文本区域不起作用
- 从 Angular 中声明的子窗口调用主窗口中的函数
- 在点击事件上从父窗口调用子窗口的功能在 Safari 和 Chrome 上不起作用
- 从模式弹出窗口调用 SignalR Javascript 函数
- 如何将JSON对象传递到通过模态窗口调用的PHP文件
- 从弹出窗口调用主窗口
- 从父窗口调用Iframe中的函数
- 从子窗口调用父窗口的JavaScript
- 如何从子窗口调用父窗口函数
- IIFE单例全局未定义,除非作为窗口调用.Xyz = ilife()
- 我有js在xul文件,我想从主窗口调用特定的函数
- 从子窗口调用操作,关闭子窗口并重新加载父页面
- 如何使用窗口.调用页方法的位置
- 我怎么能从谷歌地图信息窗口调用Angular2函数呢?
- 加载时在新窗口调用函数
- 从弹出窗口调用操作
- 从vb.net的模态窗口调用javascript函数