This is a basic piece of code that write a couple of links to the webpage:

in the xhtml file (1.0 Strict): <script type="text/javascript" src="file.js"></script> in the file.js file:

document.write("<p><a href="link1.html">Title</a></p>");
document.write("<p><a href="link1.html">Title</a></p>");
document.write("<p><a href="link1.html">Title</a></p>");
document.write("<p><a href="link1.html">Title</a></p>");

The links aren't there, the titles are there, THERE IS NOTHING THERE!!!!! =/

Hi Jimbo,

The document.write method won't work if you are using the .xhtml extention in your document. But if you want to stick using this method, then simply change your (x)HTML document using the .html extention.

Good day...

which other method should I use then? The file is .html the Doctype is XHTML strict

it would be better if you will use:

document.getElementById("yourElementId).innerHTML = "<a href=\"somefile.html\">Link</a>"; // This Method applies to all modern browsers

document.all["yourElementId"].innerHTML = "<a href=\"somefile.html\">Link</a>"; // Goes with the IE Mode Browser.

and also by using this .xhtml extention, your page will not get rendered in any version of IE browser.

You've just missed something in your code that's why it's not working:

try changing all your lines and you must escape all double quoted string inside your code:
e.g.

document.write("<a href=\"link1.html\">Link</a>"); // or

document.write('<a href="link1.html">Link</a>'); // Use a single quote when you are implementing double quoted properties inside your string.
This question has already been answered. Start a new discussion instead.