window.opener.document 为空或不是对象

ILOVE_ASPNET 2012-05-02 02:13:35
var a = window.opener.document.getElementById("MainContent_btnImportWebSite").style.display='none' ;
为什么没效果

var a = window.opener.document.getElementById("MainContent_txtSKU").value='xxx';
一样也是报错
信息为:window.opener.document 为空或不是对象
...全文
481 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
ILOVE_ASPNET 2012-05-02
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 的回复:]

iframe 是 window.parent.document
[/Quote]

是的回楼上的, OK了,感谢。。。
rayyu1989 2012-05-02
  • 打赏
  • 举报
回复
iframe 是 window.parent.document
ILOVE_ASPNET 2012-05-02
  • 打赏
  • 举报
回复
window.opener 难道一定要是 父页面要以 window.open() 的方式打开的子页面才能这样赋值吗??
ILOVE_ASPNET 2012-05-02
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]

window.opener.document.getElementById("MainContent_txtSKU").value='xxx';
window.opener.document.getElementById("MainContent_btnImportWebSite").style.display='none' ;
直接这么写有错?
[/Quote]

回楼上的话,这样写就报错,错误信息提示为空或不是对象,肯定是对的呀,我在父面面是asp.net控件, 难道只能对html控件才有作用?还是我代码写的有问题?
ILOVE_ASPNET 2012-05-02
  • 打赏
  • 举报
回复
是的,我父窗体有个按钮,初始化是隐藏的,当子窗体OK之后我要设置父窗体的按钮可见
三石-gary 2012-05-02
  • 打赏
  • 举报
回复
window.opener.document.getElementById("MainContent_txtSKU").value='xxx';
window.opener.document.getElementById("MainContent_btnImportWebSite").style.display='none' ;
直接这么写有错?
三石-gary 2012-05-02
  • 打赏
  • 举报
回复
var a = document.getElementById("MainContent_btnImportWebSite").style.display='none'
你是想干什么啊。。前面为什么要加 window.opener.

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧