将邮政编码带到新窗口中的新字段
我的 html 字段上有一个只读字段,其名称为 _Dataaddr_postcode 我现在需要捕获此数据并将其传递到一个新窗口中,该窗口加载另一个文件 (proxcomp.asp) 并使用此页面上的字段中的数据字段的 ID 为 inpAddr。
到目前为止我有这段代码
<script type="text/javascript">
var pcodeStart = document.getElementbyId("_Dataaddr_postcode");
var newWindow;
function makeNewWindow( ) {
if (!newWindow || newWindow.closed) {
newWindow = window.open("../hpwprox/proxcomp.asp","sub","status=0,title=0,height=600,width=800");
setTimeout("writeToWindow( )", 50);
} else if (newWindow.focus) {
newWindow.focus( );
}
}
</script>
<input type="button" value="Create New Window" onclick="makeNewWindow();" />
有人可以告诉我如何用一些示例代码来实现这一点吗?
谢谢
贾斯汀。
I have a read only field on a html field which has a name of _Dataaddr_postcode I now need to capture this data and pass it into a new window which loads another file (proxcomp.asp) and use the data in a field on this page the field has an ID of inpAddr.
I have this code so far
<script type="text/javascript">
var pcodeStart = document.getElementbyId("_Dataaddr_postcode");
var newWindow;
function makeNewWindow( ) {
if (!newWindow || newWindow.closed) {
newWindow = window.open("../hpwprox/proxcomp.asp","sub","status=0,title=0,height=600,width=800");
setTimeout("writeToWindow( )", 50);
} else if (newWindow.focus) {
newWindow.focus( );
}
}
</script>
<input type="button" value="Create New Window" onclick="makeNewWindow();" />
Can someone tell me how to achieve this with some sample code?
Thanks
Justin.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
仅将该一个字段作为表单输入传递到服务器端脚本:
如果您希望使用客户端代码而不是服务器端代码在弹出窗口中设置文本框,则需要从弹出窗口中执行此操作向上窗口以避免您否则会添加的延迟以及页面加载时间相互“竞争”的情况。在 JavaScript 中,全局变量是它们所在的窗口对象的属性,并且
window.opener
给出打开此窗口的窗口。请注意,由于同源政策,两者Windows 的 URL 中需要具有相同的协议、主机名和端口号。如果您愿意,可以省略
window.opener
的window.
部分,前提是您没有使用名为opener
的变量。Passing just that one field as a form input to the server-side script:
If you wish to use client-side code to set a textbox in the pop-up rather than server-side code, you need to do it from the pop-up window to avoid the delay you would add otherwise and the page's load time from "racing" each other. In JavaScript, global variables are properties of the window object they exist inside of, and
window.opener
gives the window that opened this one. Note that because of the same-origin policy, the two windows need to have the same protocol, hostname, and port number in their URLs.You can omit the
window.
part ofwindow.opener
if you want to, provided that you are using no variable calledopener
.也许这样做:
或者从打开的窗口:
请阅读这篇精彩的文章!
Maybe doing this:
Or from the open window:
Please read this great article!