Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Text possible at runtime? 1

Status
Not open for further replies.

Smarty

Programmer
Apr 12, 2001
191
BE
I've got this problem to solve... I've got to print a first text at x-y coordinates 80-400, and a few seconds afterwards i have to display a text at x-y coordinates 10-10. I do it with server push, but is it possible with DHTML to print two DIV tags in the body, the first with the bottomright text, and afterwards in my html file the second with the upperleft text?

Is it possible with a variable number of messages, a variable x-y position and a variable message?
 
sure, if you are using a modern browser (5+), it's kinda easy:

function newMessage(text,x,y)
{
var el = document.createElement("DIV");
el.style.position = 'absolute';
el.style.left = x+"px";
el.style.top = y+"px";
el.innerHTML = text;
return document.body.appendChild(el);
}

currmessage = newMessage("Message 1",500,300);

when you want to hide the old one and make a new one:

currmessage.style.display = 'none';
currmessage = newMessage("Message 2",250,150) jared@eae.net -
 
Thanx jaredn,

This post was exactly what i was looking for!!!

 
No problem... just remembered, instead of:

currmessage.style.display = 'none'

you may want to use:

document.body.removeChild(currmessage)

as it should avoid memory leaks,etc... jared@eae.net -
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top