View Single Post
  #1 (permalink)  
Old Dec 1st, 2007, 03:07
alexhkleung alexhkleung is offline
Junior Member
Join Date: Nov 2007
Location: Hong Kong
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
need help on innerHTML

i've been trying to print some message in <div id="information">
these messages were stored in the var info

here's the html code
HTML: Select all
<body><div id="hello">Hello!</div>
<div id="infromation"></div>
</body>
and the JS
Code: Select all
var whatisthis = window.location.href.split("/");
var last= whatisthis.length -1;
var nohtml = whatisthis[last].split(".");
last = nohtml.length -2;
var info = "<h3>Title: </h3>" + "<p> Tutorial " + nohtml[last] + "</p>";

document.getElementById("information").innerHTML = document.write(info);
at the moment nothing could be printed
if i change the last line to document.write(info);
i get the message that i want though it is not printed inside the information div

How can i get those message to be printed in specific div??
thx!

Last edited by karinne; Dec 3rd, 2007 at 14:35. Reason: Please use vBcode when inserting code in your post.
Reply With Quote