为什么document.getElementyById不能在Windows 10上的IE11中运行 - 什么是dispHTMLDocument? [英] why won't document.getElementyById work in IE11 on Windows 10 - what is dispHTMLDocument?

查看:442
本文介绍了为什么document.getElementyById不能在Windows 10上的IE11中运行 - 什么是dispHTMLDocument?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本可以在JavaScript中执行最简单的操作 - 使用getElementById在DOM中查找元素。我有一个简单的"输入"按钮  - < input type =" button"带有onclick事件的页面上的元素 - 调用
脚本函数。   函数的第一行是  var elem = document.getElementById('[elementname]');这在大多数机器和大多数浏览器上运行良好 - 除了IE11在某些计算机上的Windows 10上运行。 当这些用户在Windows 10上使用IE11访问
网页并单击输入按钮时,它会运行onclick脚本并在第一行代码上失败。  在一台计算机上,它显示错误类似于文档对象的东西没有名为getElementById的方法。 
在另一台计算机上,它甚至没有显示错误 - 它只是尝试执行第一行并立即停止运行任何脚本并中止返回页面而不会抛出错误。 当我查看机器上的文档对象
(win 7 IE11)时,它会评估"文档"。作为"对象"和"HTMLDocument"。 当我在失败的计算机上评估文档对象时,它评估"文档"。作为"对象"和"dispHTMLDocument"。 
不确定dispHTMLDocument是什么,我不知道为什么它不能识别getElementById方法。


我需要某种修复方法 - 这些有关键功能用户无法运行...有没有办法将dispHTMLDocument转换为HTMLDocument? 是否有浏览器设置我可以更改以解决此问题? 我可以要求他们用
安装或升级一些东西 - 比如java版本 - 来解决这个问题吗?


我甚至不知道从哪里开始。  :( 感谢您的帮助!




ahuitt

解决方案

我在运行IE 11的Windows 10中做了很多getElementByID。到目前为止我没有看到任何问题。


你试过吗?这是IE 11中的简单代码,可以运行。


http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_document_getelementbyid

<!DOCTYPE html> 
< ; html>
< body>

< p id =" demo">点击按钮更改此段落中的文字。< / p>

< button onclick =" myFunction()">试试吧< / button>

< script>
function myFunction(){
document .getElementById(" demo")。innerHTML =" Hello World";
}
< / script>

< / body>
< / html>


chanmm


I have a script that does the most simple thing in JavaScript - finds an element in the DOM using getElementById. I have a simple "input" button - <input type="button" element on the page with an onclick event - which calls a script function.  The first line of the function is  var elem = document.getElementById('[elementname]'); This all runs fine on most machines and most browsers - except IE11 running on windows 10 on some computers.  When these users visit the webpage using IE11 on windows 10 and click the input button, it runs the onclick script and fails on the first line of code.  On one persons computer, it shows an error that says something like document object doesn't have a method named getElementById.  On another persons computer it doesn't even show an error - it just tries to execute the first line and immediately stops running any script and aborts back to the page without ever throwing an error.  When I look at the document object on my machine (win 7 IE11) it evaluates "document" as "object" and "HTMLDocument".  When I evaluate the document object on computers that fail, it evaluates "document" as "object" and "dispHTMLDocument".  Not sure what dispHTMLDocument is and I have no idea why it doesn't recognize the getElementById method.

I need some kind of fix for this - there is key functionality that these users can't run... is there any way to convert the dispHTMLDocument into an HTMLDocument?  Is there a browser setting I can change to fix this problem?  Can I ask them to install or upgrade something - like a java version - to fix this?

I don't even know where to start.  :(  Thanks for any help!


ahuitt

解决方案

I am doing quite a lot of getElementByID in my Windows 10 running IE 11. I don't see a problem so far.

Have you try this is simple code in your IE 11 and can it run.

http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_document_getelementbyid

<!DOCTYPE html>
<html>
<body>

<p id="demo">Click the button to change the text in this paragraph.</p>

<button onclick="myFunction()">Try it</button>

<script>
function myFunction() {
    document.getElementById("demo").innerHTML = "Hello World";
}
</script>

</body>
</html>

chanmm


这篇关于为什么document.getElementyById不能在Windows 10上的IE11中运行 - 什么是dispHTMLDocument?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆