Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7649529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:59:22+00:00 2026-05-31T10:59:22+00:00

Just trying to set up a little test page and even it doesn’t behave

  • 0

Just trying to set up a little test page and even it doesn’t behave as expected.

Given the following working code:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8">
<title>Terry's Test Page</title>
<script src='jquery-1.7.1.min.js'></script>
</head>
<body>
    <p>from the html in index.html</p>
</body>
</html>

I get what I expect, the one line from the html and Terry’s Test Page in the tab label. However, if I add just before the </head> line:

<script>$(document).ready(function() {
document.write('<p>from the js</p>');
});
</script>

I properly get the ‘from the js’ line — no from html since document.write replaces it — but the tab label is not filled with Terry’s Test Page. In IE the tab label shows the url, in Firefox it shows ‘Connecting …’ but it never gets beyond that.

What is it about document.write that I don’t understand? Do I have to issue some sort of end of file or some such?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T10:59:24+00:00Added an answer on May 31, 2026 at 10:59 am

    Since you call document.write after page load, it calls document.open, which empties the whole document. The browser does its best and creates a complete new document with what you provide. The document is not only the content in the body, but everything else as well.

    In your case, your document is <p>from the js</p>, but since this is not a valid HTML document (missing html, head and body), the browser will add what’s necessary.

    For example take

    document.write('<head><title>foo</title></head>');
    

    This will just create an empty body, but set the title of the page to foo.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started working using Google Maps API yesterday, and trying to set up
just trying to test for equality in this piece of code, but getting a
I've been trying to make a little simple game just to test my logics,
I'm trying to set the ForceCheckout property on an SPList item and it's just
I've just set up mod python with apache and I'm trying to get a
I am just trying to compile and run a very simple test program, but
I'm trying to write a little CLI Hangman game, just to create something in
I'm trying to create a little test application which reads chunks of a FileStream
I have a little sample application I was working on trying to get some
I've been trying to set up Notepad++ as a little Java environment, mainly for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.