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!

function to update window status

Status
Not open for further replies.

airswit

Programmer
Apr 19, 2003
23
US
hey, i want to make a function in javascript that will update the window status in netscape. now, i want to call it like this:

onmouseover="set('New Status');"

or something like that, then another that resets it, back to '':

onmouseout="reset();"

now, i have the reset func working fine and dandy, but i cant get the set func to work right. here is the function, i know it is probably some stupid mistake, but any help would be great:

function set(text) { window.status=text; return true; }

pretty new to javascript, so don't laugh too hard! haha
 

Try this:

Code:
onmouseover="set('New Status'); return(true);"

Basically, moving the return(true) from the function to the onmouseover declaration.

Hope this helps,
Dan

 
well, the whole point of me doing it in a function, is so that i wouldn't have all those return statements in the quotes, so if there is another solution, that would be great
 

>> well, the whole point of me doing it in a function, is so that i wouldn't have all those return statements in the quotes

But did you try the code I gave? You didn't stipulate in your question that you only wanted the problem solved in a specific way, so sorry if my code was not up to scratch.

Dan
 
well u could try this:
Code:
function set(text,Lnk)
{
window.status=text;
Lnk.onmouseout=SetBack()
}
function SetBack()
{
 status=""
}

call it like this:
onmouseover="set('New Status',this);"

Known is handfull, Unknown is worldfull
 
vbkris, that code you gave me gives me an error on the "lnk.onmouseover=" line, says "not implemented". am i not able to do this, or is it something i wrote wrong?
 
give me sometime, i will test it

Known is handfull, Unknown is worldfull
 
Note:
The setting of the status is wrong, u may want to change it.
The error has been rectified....
Code:
<script>
function set(text,Lnk)
{
status=text; //change this to a timer
Lnk.onmouseout=SetBack //The() was the error
}
function SetBack()
{
 status="Out"
}
</script>
<a href="" onmouseover="set('asd',this)">Link</a>


Known is handfull, Unknown is worldfull
 
k, i tried the code that you gave, but there is a problem, at least when i am running it. it seems that it updates the status after the mouse leaves the area, which means you see no effect! i learned this by omitting the onmouseout line, and when the mouse left the link, i saw the text i expected to see when the mouse was over the link. while the mouse is over the link, it just shows the location of the link!
 
that is what i meant by asking u to reconsider ur status code, u have to set it in a timer, there is no other way...

Known is handfull, Unknown is worldfull
 
can you expand on that, i don't know what a timer is, i don't think. i usually set my status this way, just i usually put:

Code:
onmouseover="window.status='status text'; return true;"

inside of the <a> tag in the html file. when i thought to do it in a separate javascript func, i thought i could just do it in this same fasion.
 
use in the head section:
Code:
<script language="javascript">
var statusText = "";
var myTimer = window.setInterval(500, setStatus());

function setStatus()
{
     window.status = statusText;
}
</script>

and replace onmouseover with:
Code:
onmouseover="statusText = 'new status text';"
 
i have integrated dazzled's code with mine:
Code:
function set(text,Lnk)
{
setInterval("setStatus('"+text+"')",100);
Lnk.onmouseout=SetBack //The() was the error
}
function SetBack()
{
 status="Out"
}
function setStatus(text)
{
     window.status = text;
}
</script>
<a href="" onmouseover="set('asd',this)">Link</a

Known is handfull, Unknown is worldfull
 
aw man, still a problem, but getting better! now, i get the text i want in the status bar, but it like, sets the text back to '' (that's what i have 'setback()' put it as), but then sets it back to the text i send to the func in the 1st place!! ps, thanks for all your help thus far, you have been great!
 
Code:
<script>
var timer
function set(text,Lnk)
{
timer=setInterval("setStatus('"+text+"')",100);
Lnk.onmouseout=SetBack //The() was the error
}
function SetBack()
{
 status="Out"
 clearInterval(timer)
}
function setStatus(text)
{
     window.status = text;
}
</script>
<a href="" onmouseover="set('asd',this)">Link</a>

Known is handfull, Unknown is worldfull
 
woohoo, than you soo much! finally, it works
 
ur welcome....

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top