title: document.write in html/php doc writes to new page
body: <p>I'm trying to write a piece of text over an existing web page based on whether or not the cookie is set. The cookie part works fine, but the document.write causes the text to appear on a new blank page.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function getCookie(c_name)
  {
  var i,x,y,ARRcookies=document.cookie.split(";");
  for (i=0;i&lt;ARRcookies.length;i++)
  {
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
  {
  return unescape(y);
  }
  }
  }
  
  function setCookie(c_name,value,exdays)
  {
  var exdate=new Date();
  exdate.setDate(exdate.getDate() + exdays);
  var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
  document.cookie=c_name + "=" + c_value;
  }
  
  function checkCookie()
  {
  var username=getCookie("username");
  if (username!=null &amp;&amp; username!="")
  {
  alert("Welcome again " + username);
  }
  else
  {
  username=prompt("Please enter your name:","");
  document.write ("hello"); 
  if (username!=null &amp;&amp; username!="")
  {
  setCookie("username",username,7);
  
  }
  }
  }
  &lt;/script&gt;
  
  
  &lt;body onload="checkCookie()"&gt;
  
  &lt;/body&gt;
  </code></pre>
  
  <p>I guess I need to use a z-index somehow, but can't seem to get it to work. If someone could explain how I get my 'document.write' line to appea on top of the stuff that already exists on the page, I would be really grateful.  All of this is happening on a page on a joomla site, and the code is in the php file for one of the modules.  Thanks all.</p>
  
  <p>Rob.</p>