简体   繁体   English

IE中的document.write

[英]document.write in IE

I haven't checked with IE9 but I have a simple JS that utilizes document.write to display some information. 我没有用IE9进行检查,但是我有一个简单的JS,它利用document.write显示了一些信息。 It works on every browser except IE 6, 7, 8. I checked all my other code and when I decided to eliminate all of it and simply put 它适用于除IE 6、7、8之外的所有浏览器。我检查了所有其他代码,并决定删除所有代码,然后简单地输入

document.write(Testing);

I got nothing from IE. 我没有从IE获得任何信息。 Is there another command I can use. 还有其他我可以使用的命令。 I am new to Javascript. 我是Java语言的新手。

I'm not sure how your original code is using document.write, but you could achieve more or less the same effect this way: 我不确定您的原始代码如何使用document.write,但是您可以通过以下方式实现大致相同的效果:

<div id="outputGoesHere"></div>
<script type="text/javascript">
    document.getElementById("outputGoesHere").innerHTML = "Testing";
</script>

试试: document.write('Testing');

We were having this problem earlier today and luckily our page already had access to jquery... 今天早些时候我们遇到了这个问题,幸运的是我们的页面已经可以访问jquery ...

Replacing document.write(variableWithYourValue) with $('html').html(variableWithYourValue) did the trick for us. $('html').html(variableWithYourValue)替换document.write(variableWithYourValue)为我们成功了。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM