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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

document.write to current page 2

Status
Not open for further replies.

phanta

Technical User
Apr 23, 2003
5
BE
hello,

i'm new into javascript. I want to call a function with a mouseoverevent:

onMouseOver="javascript:SetExpl('Startpage, overview of the site')"

Here is the function:

<script language="JavaScript">
function SetExpl(theText)
{
document.write(theText);
} </script>

The problem: I' want to set the text after the mouseoverevent on the current page but when i do a mouseover, the text comes on a new pages.
Did somebody had the same problem?
 
You could try this:

Put the text that you to apear in a <div> wherever you want it to appear.use javascript to make it appear when u want it to.
here's an example:
<html>
<head>
<script type="text/javascript">
function callfunc()
{
var currId = test1.id;
document.getElementById(currId).style.visibility="visible";

}
</script>
</head>
<body>
<form>
<input type=text onmouseover="callfunc();">

<div id="test1" style="visibility:hidden;">
Some text here!!!
</div>

</form>
</body>
</html>

hope this helps.
rsshetty.

It's always in the details.
 
or...
you could simply write to a div box which is always present, like so...


function bologna(){
document.getElementById("DivX").innerHtml="Oscar Meyer makes me puke";
}

<body>
<form name="ChickenNuggets">
<div id="DivX" name="prettyNess" style="width:100" style="height:100">
</form>
<button onClick="bologna()">Clik</button>


walla!
 

Although not really important for the example, you should specify the units for width and height when using CSS:

Code:
style="width:100px;height:100px"

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top