I am attempting to write a bit of text over a current web site according to set up cookie is placed. The cookie part works fine, however the document.write causes the written text to look on the new blank page.

<script type="text/javascript">
function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<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 && username!="")
{
alert("Welcome again " + username);
}
else
{
username=prompt("Please enter your name:","");
document.write ("hello"); 
if (username!=null && username!="")
{
setCookie("username",username,7);

}
}
}
</script>


<body onload="checkCookie()">

</body>

I suppose I have to make use of a z-index in some way, but can't appear to have it to operate. If a person could let you know that I recieve my 'document.write' line to appea on the top from the items that already is available around the page, I'd be really grateful. All this is going on on the page on the joomla site, and also the code is incorporated in the php apply for among the modules. Thanks all.

Take advantage of.

[cde] ought to be prevented.

It's couple of (perhaps) valid use cases, which can be used inline inside a document.write() element and performed because the page is loaded.

If you use it past the page load, it'll unconditionally call [cde] that will obvious your page.

You need to favour modern standardised DOM techniques.

I believe you need to define a component inside your Markup, in which the message ought to be added.

script

So that you can just add your Message in to the "message"-div:

document.open()

Assign your body an ID, for example 'body', then make use of the following:

<div id="wrapper">
<div id="message"></div>
<div id="content">
...
</div>
</div>

W3 Schools includes a good example of it.