母版页和 JavaScript 问题
我准备了一个aspx文件,可以使用(window.open)命令打开一个新窗口。在子窗口中,一些值通过(.innerHTML)命令发送到父页面,并且它可以自行关闭。但是,在我将母版页设置为父页面后,命令无法从新窗口向父窗口发送任何值,并且它无法自行关闭。
母版页如何影响我的 javascript 命令?
谢谢
编辑:作者drachenstern(我尽我所能用我所拥有的...这是他粘贴的内容)
从子代码后面:
<br> Page.RegisterStartupScript("CLOSE",
"<...JS...><script type=\"text/javascript\">" +<br>
"window.opener.document.getElementById('TableID').innerHTML = \"" + RadioNumber + "\";" +<br>
"window.opener.document.getElementById('HiddenTableID').value = \"" + RadioNumber + "\";
<br>
self.close();" +
"<...JS....></script>"
);<br>
父方:
<br>
..a ..<br>href="javascript:window.open('SelectTable.aspx','OPEN','toolbar=no,directories=no,status=no,titlebar=no,menubar=no,scrollbars=no,resizable=no,width=800,height=600,top=0,left=0,');"/>SelectSomthng<br>../a..
第二次编辑:(又是龙) 看起来这就是意图
从子代码后面:
Page.RegisterStartupScript("CLOSE",
"<...JS...><script type=\"text/javascript\">" +
"window.opener.document.getElementById('TableID').innerHTML = \"" + RadioNumber + "\";" +
"window.opener.document.getElementById('HiddenTableID').value = \"" + RadioNumber + "\"; +
self.close();" + "<...JS....></script>");
父端:
/* drachenstern: notice I put the carriage returns for legibility, not in the original code*/
<a href="javascript:window.open(
'SelectTable.aspx',
'OPEN',
'toolbar=no,directories=no,status=no,titlebar=no,menubar=no,
scrollbars=no,resizable=no,width=800,height=600,top=0,left=0,'
);"/>SelectSomthng</a>
I prepared an aspx file that can open a new window with (window.open) command. In the child window, some values send to parent page with (.innerHTML) command and it can close itself . However, after I set a master page to parent page , command can not send any value from new window to parent and it can not close itself.
How master page can affect my javascript commands?
Thanks
EDIT: By drachenstern (I do what I can with what I have ... this is what he pasted)
From child code behind:
<br> Page.RegisterStartupScript("CLOSE",
"<...JS...><script type=\"text/javascript\">" +<br>
"window.opener.document.getElementById('TableID').innerHTML = \"" + RadioNumber + "\";" +<br>
"window.opener.document.getElementById('HiddenTableID').value = \"" + RadioNumber + "\";
<br>
self.close();" +
"<...JS....></script>"
);<br>
Parent side:
<br>
..a ..<br>href="javascript:window.open('SelectTable.aspx','OPEN','toolbar=no,directories=no,status=no,titlebar=no,menubar=no,scrollbars=no,resizable=no,width=800,height=600,top=0,left=0,');"/>SelectSomthng<br>../a..
SECOND EDIT: (again drachenstern)
It would appear this is the intention
From child code behind:
Page.RegisterStartupScript("CLOSE",
"<...JS...><script type=\"text/javascript\">" +
"window.opener.document.getElementById('TableID').innerHTML = \"" + RadioNumber + "\";" +
"window.opener.document.getElementById('HiddenTableID').value = \"" + RadioNumber + "\"; +
self.close();" + "<...JS....></script>");
Parent side:
/* drachenstern: notice I put the carriage returns for legibility, not in the original code*/
<a href="javascript:window.open(
'SelectTable.aspx',
'OPEN',
'toolbar=no,directories=no,status=no,titlebar=no,menubar=no,
scrollbars=no,resizable=no,width=800,height=600,top=0,left=0,'
);"/>SelectSomthng</a>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想在子窗口中获取父页面的控制权并使用父页面的母版页...那么您可以使用以下方法来获取输入类型或任何其他类型的控制权,使用
您可以遍历集合的 TagName通过
indexOf()
方法找到您想要的 id 并执行您想要的任何操作。if you want to get the control of parent page in the child window and using master page for the parent page... then you can use following to get the control of input type or any other type using the TagName
you can traverse through the collection to and find the id you want by
indexOf()
method and perform whatever things you want.从子代码后面:
Page.RegisterStartupScript("CLOSE",
“<...JS...>” +
"window.opener.document.getElementById('TableID').innerHTML = \"" + RadioNumber + "\";" +
"window.opener.document.getElementById('HiddenTableID').value = \"" + RadioNumber + "\";" +
“self.close();” +
“<...JS...>”
);
父方:
..a ..
href="javascript:window.open('SelectTable.aspx','OPEN','工具栏=否,目录=否,状态=否,标题栏=否,
菜单栏=否,滚动条=否,可调整大小=否,宽度=800,高度=600,顶部=0,左侧=0,');"/>SelectSomthng
../a..
From child code behind:
Page.RegisterStartupScript("CLOSE",
"<...JS...>" +
"window.opener.document.getElementById('TableID').innerHTML = \"" + RadioNumber + "\";" +
"window.opener.document.getElementById('HiddenTableID').value = \"" + RadioNumber + "\";" +
"self.close();" +
"<...JS....>"
);
Parent side:
..a ..
href="javascript:window.open('SelectTable.aspx','OPEN','toolbar=no,directories=no,status=no,titlebar=no,
menubar=no,scrollbars=no,resizable=no,width=800,height=600,top=0,left=0,');"/>SelectSomthng
../a..