I have nothing on a page except the following:
<script type="text/javascript" 开发者_运维问答src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script>
$(function() {
document.write('foo');
});
<script>
When I run this page in firefox the loading indicator in the current browser tab seems to be in perpetual motion, never stopping. Why does this happen? Is it indicating that the document.write script runs ceaselessly?
You need to close the document after you've written to it:
document.write('foo');
document.close();
Otherwise the browser still has the document in an "open-for-writing" state, hence the loading indicator.
(Also, as @DaveRandom points out in his comment, you need close your <script>
properly with </script>
.)
精彩评论