简体   繁体   English

document.getElementById('inner')。innerHTML =“ message”; 给我IE错误

[英]document.getElementById('inner').innerHTML=“message”; is giving me an error with IE

Here is the java script 这是Java脚本

window.onload="test";

  function test() {

     document.getElementById('inner').innerHTML="message";

  }

Here is the html page I am loading up in IE 这是我正在IE中加载的html页面

<h1 class="serif">FDM Markets Trading Platform</h1>


<div class="layout" />  
 <div class="center">  
  <p class="paragraph">Login</p>
  <form name="anyForm">
   <span class="formlabel1">Username</span><input type="text" name="anyName" onKeyUp="Complete(this, event)" /></br>
   </br>
   <span class="formlabel2">Password</span><input type="text" name="password_box"></br>
   </br>
  </form>
  <span id="clock">&nbsp;</span>
 </div>
</div>

<div id="outer">

<div id="inner"></div>

</div>

When I load the page "message" doesnt appear in webpage and i get error that says object is null or undefined. 当我加载页面时,“消息”没有出现在网页中,并且我得到一个错误,提示对象为null或未定义。

Your onload handler is wrong. 您的onload处理程序有误。 It should be this: 应该是这样的:

  function test() {

     document.getElementById('inner').innerHTML="message";

  }
  window.onload = test;

You pass a javascript function reference to .onload , not a string. 您将一个JavaScript函数引用传递给.onload ,而不是字符串。

暂无
暂无

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

相关问题 document.getElementById()。innerHTML在IE中失败并显示“未知错误” - document.getElementById().innerHTML fails with 'Unknown Error' in IE IE的AJAX document.getElementById()。innerHTML问题? - AJAX document.getElementById().innerHTML problem with IE? document.getElementById('keylink').innerHTML = '<a></a> '; 不在ie中工作 - document.getElementById('keylink').innerHTML = '<a ></a>'; not working in ie document.getElementById()。innerHTML不起作用,控制台上没有错误 - document.getElementById().innerHTML not working, no error on console Js, document.getElementById(&quot;ID&quot;).innerHTML, 错误 - Js, document.getElementById("ID").innerHTML, error document.getElementById(&#39;grand_total_display&#39;)。innerHTML =“总计为:$” +变量; 在IE6和IE7中显示错误 - document.getElementById('grand_total_display').innerHTML = “Total is : $”+variable; is displaying error in IE6 and IE7 document.getElementByID(&quot;test&quot;).innerHTML 给出 TypeError: &#39;undefined&#39; is not a function (evaluating &#39;document.getElementByID(&quot;test&quot;)&#39;) - document.getElementByID(“test”).innerHTML giving TypeError: 'undefined' is not a function (evaluating 'document.getElementByID(“test”)') IE中的document.getElementById - document.getElementById in IE 为什么document.getElementById('tableId')。innerHTML在IE8中不起作用? - Why is document.getElementById('tableId').innerHTML not working in IE8? select标签的document.getElementById()。innerHTML在IE中不起作用 - document.getElementById().innerHTML for select tag doesn't work in IE
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM