最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - document.write in IE - Stack Overflow

programmeradmin6浏览0评论

I haven't checked with IE9 but I have a simple JS that utilizes document.write to display some information. 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

document.write(Testing);

I got nothing from IE. Is there another mand I can use. I am new to Javascript.

I haven't checked with IE9 but I have a simple JS that utilizes document.write to display some information. 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

document.write(Testing);

I got nothing from IE. Is there another mand I can use. I am new to Javascript.

Share Improve this question asked Mar 25, 2011 at 19:40 smulholland2smulholland2 1,1632 gold badges14 silver badges29 bronze badges 3
  • 1 Not an answer.. but it sounds like you may want to spend some quality time with jQuery... – Shane Courtrille Commented Mar 25, 2011 at 19:43
  • Add quotation marks around Testing and see what that does. – Blender Commented Mar 25, 2011 at 19:44
  • 2 Testing is an undefined variable. But you should not use document.write anyway. Create a new DOM element instead. – Felix Kling Commented Mar 25, 2011 at 19:45
Add a ment  | 

3 Answers 3

Reset to default 4

I'm not sure how your original code is using document.write, but you could achieve more or less the same effect this way:

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

try: document.write('Testing');

We were having this problem earlier today and luckily our page already had access to jquery...

Replacing document.write(variableWithYourValue) with $('html').html(variableWithYourValue) did the trick for us.

发布评论

评论列表(0)

  1. 暂无评论