简体   繁体   English

为什么此Javascript代码无法在Firefox和Chrome中执行?

[英]Why won't this Javascript code execute in Firefox & Chrome?

I have this set of Javascript code that works fine in IE (any version), but won't work on Mozilla Firefox or Google Chrome. 我有这套Javascript代码,可以在IE(任何版本)中正常工作,但在Mozilla Firefox或Google Chrome上无法使用。 Can someone advise me why? 有人可以告诉我为什么吗?

function returnData(strCode,strProgramCode,strName)
    {           
        parent.opener.document.all.txtCourseCode[7].value = strCode;      
        parent.opener.document.all.txtProgram[7].value = strProgramCode;                                                
        parent.opener.document.getElementById("txtCourseName8").innerHTML = strName;                

        window.close()
}

FYI, this Javascript is embedded into a .aspx page that was written using .NET Framework 1.1. 仅供参考,此Javascript嵌入使用.NET Framework 1.1编写的.aspx页中。

Edit Doesn't work means: none of the lines executed although they were explicitly invoked. 编辑不起作用意味着:尽管显式调用了任何行,但均未执行。

Example: window.close() doesn't close the window 示例: window.close()不关闭窗口

document.all is an IE-only property, so obviously it won't work in other browsers. document.all是仅IE的属性,因此显然在其他浏览器中将无法使用。

You shouldn't use document.all anyway. 无论如何,您都不应该使用document.all By the look of things, you're actually wanting: 从外观上看,您实际上想要的是:

parent.opener.document.getElementsByName('txtCourseCode')[7].value = strCode;
parent.opener.document.getElementsByName('txtProgram')[7].value = strProgramCode;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 单击下载按钮后,为什么Firefox不会执行JavaScript代码? - Why won't Firefox execute JavaScript code after a download button click? 如果Jquery异步加载,为什么此Javascript代码无法在Chrome上运行? - Why this Javascript code won't work on Chrome if Jquery loads as async? 为什么这个代码不能在IE11,Chrome,Firefox中运行,但是可以在IE8中运行? - Why won't this code work in IE11, Chrome, Firefox, but will work in IE8? 浏览器不会执行部分JavaScript代码 - Browser won't execute part of javascript code JavaScript无法执行-仅显示代码 - javascript won't execute - only displays code javascript无法执行,但会打印代码 - javascript won't execute but prints code 为什么我的JavaScript函数不执行? - Why won't my JavaScript function execute? 如果条件执行,为什么不使用简单的Javascript? - Why won't a simple Javascript if condition execute? JavaScript按钮在Chrome和IE中完美启动,但在Firefox中不起作用 - JavaScript button fires perfectly in Chrome and IE but won't work in Firefox 有没有办法以编程方式生成一些JavaScript代码以在Chrome或Firefox调试器中执行? - Is there a way to generate programmatically some javascript code to execute in the Chrome or Firefox debugger?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM