windows .opener.location在IE中为空.在Chrome中工作良好
window.opener.location is null in IE. Works fine in Chrome.
Response.Write("<script language='javascript'>alert(window.opener.location.pathname); if(window.opener.location.pathname.toString() == '"/page.aspx'"){window.opener.document.forms[0].submit();}</script>");
这在Chrome中工作,但在IE中,我得到一个大规模的javascript运行时错误,说位置是空的,似乎它与打开器有关。
在IE中等效的是什么?
永远不要使用Response.Write
向页面添加JavaScript。查看页面源代码,您将看到在页面上的任何HTML标记之前添加了脚本。
你应该使用RegisterStartUpScript
。
ClientScriptManager cs = Page.ClientScript;
Type cstype = this.GetType();
String cstext1 = "alert(window.opener.location.pathname);";
cs.RegisterStartupScript(cstype, "alert", cstext1, true);
试试window.opener.document.location
:
Response.Write("<script language='javascript'>alert(window.opener.document.location.pathname); if(window.opener.document.location.pathname.toString() == '"/page.aspx'"){window.opener.document.forms[0].submit();}</script>");
相关文章:
- JS可以在Chrome中工作,但不能在Firefox中工作
- jQuery Datepicker可以在Safari中工作,但不能在FF或Chrome中工作
- Javascript的某些部分在Chrome中不起作用,但在其他浏览器中可以完美工作
- javascript window.open将无法在Chrome控制台上工作
- 如何编写在Chrome和IE中正常工作的JavaScript
- 只有当Javascript控制台在chrome上打开时,Javascript才能工作
- NaN:Firefox和IE中的NaN,CHROME工作正常
- jquery日期转换chrome工作,但IE和firefox't
- Chrome工作区无法使用源地图和Javascript
- 数组比较在Chrome工作,但不与Chrome IPAD
- 如何获得一个值从选项时选择(此代码为chrome工作)
- HTML表单与javascript得到"在IE,但在Chrome工作
- 简单的脚本与onclick事件在Chrome工作良好,但在Firefox失败
- 在Firefox剑道按钮文本不改变,而在IE和Chrome工作
- Ajax GIF加载器不工作在IE和Firefox(最新),但在Chrome工作
- Firefox返回TypeError: document.getElementById(..)为空,但Chrome工作正
- 纯Javascript: onClick切换行/图像:Firefox/Chrome -工作:IE -不工作
- 为什么if (condition) {statements} else返回;"在Chrome工作
- 我怎么能得到jsFiddle在Chrome工作
- 模态对话框与Mozilla工作,但不与Chrome工作