Click to See Complete Forum and Search --> : window.status
David Harrison
04-06-2003, 09:50 AM
The following code will display the word Hi There at the bottom of a window when the mouse if moved over the link, and when the mouse is moved away again it will display the word Done.
However when the link is being clicked it will display something like file:///c:/windows/hithere.html.
How do I get it to still display Hi There when the link is being clicked?
<a href="hithere.html" onmouseover="window.status='Hi There';return true;" onmouseout="window.status='Done';return true;">Hi There</a>
Did you try:
<a href="hithere.html" onmouseover="window.status='Hi There';return true;" onmouseout="window.status='Done';return true;" onclick="window.status='Hi There'; return true;">Hi There</a>
David Harrison
04-06-2003, 10:00 AM
Well i just gave it a go and it didn't work, have you got any other ideas?
khaki
04-06-2003, 02:28 PM
Hi Lavalamp...
you can try it this way (you can format the text any way that you want in order
to make it look like a link if you want. i didn't do that in my example).
;) k
<html>
<head>
<style type="text/css">
a {
color:#cc0000; text-decoration: underline;
}
a:hover {
color:navy; text-decoration: underline;
}
</style>
<script language="javascript">
function doThis()
{
document.location.href="hithere.html";
}
</script>
</head>
<body>
<a onmouseover="window.status='Hi There';return true;" onmouseout="window.status='Done';return true;" onclick="doThis()">Hi There</a>
</body>
</html>
EDIT: i put some basic formatting (CSS) in my example. you can alter it any way
that you wish. if you are going to have any true links on the page, change the a to
a <div> or something.
David Harrison
04-06-2003, 02:41 PM
This is exactly what I asked for ... however, is there any way to accomplish the same thing without having any more in the script tag at the top.
Sorry, but I'm really fussy.
khaki
04-06-2003, 02:46 PM
yes
remove the javascript from above and use this instead:
<a onmouseover="window.status='Hi There';return true;" onmouseout="window.status='Done';return true;" onclick="javascript:document.location.href='hithere.html';">Hi There</a>
Note: for some reason the forum puts a space between java and script. it should all be one word (javascript)
;) k
David Harrison
04-06-2003, 03:04 PM
you must hate me so much but...
is there any way to get that dotted line around the outside of the text when it is clicked, and also is there any way to get that hand symbol to appear when the mouse is moved over it?
khaki
04-06-2003, 03:18 PM
change the style to this:
(the curser is set for both pointer and hand. i'm not sure if either one
is cross-browser all by itself.
I can only test in Netscape at the moment).
<style type="text/css">
a {
color:#cc0000;
text-decoration: underline;
}
a:hover {
color:navy;
text-decoration: underline;
cursor: pointer;
cursor: hand;
}
a:active {
border-top : 1px dashed #999999;
border-left : 1px dashed #999999;
border-right : 1px dashed #999999;
border-bottom : 1px dashed #999999;
}
</style>
One thing to consider using this method is that the link will fail for anyone who doesn't have javascript enabled. You may want to question it to be sure it is worth setting the status bar for this...
khaki
04-06-2003, 07:12 PM
oops!
sorry :eek:
I thought that this was the javascript forum ;)
nothing in here works if javascript is not enabled
(so i don't even bother to pretend otherwise)
grrr....
why must we dance this little dance time and again?
it just seems silly to me...
but... then again... i'm pretty silly!...
;) k
For something such as a link, I see no point in coding it in such a way that it will fail for everyone with javascript disabled. That, IMO, is simply bad coding...
khaki
04-06-2003, 10:40 PM
Pyro wrote: That, IMO, is simply bad coding...Fair enough... and I agree.
But I make remarks about people using tables for page layout, and about people unnecessarily using
frames for layout, and about not coding for cross-browser compatability... and yet this is what people
want to do.
So... there are supposedly 10% of users with javascript disabled. Yet this javascript forum has well
over 4,000 threads. The next highest forum here is HTML (with 999). I may really suck at math, but
that's better than a 4 to 1 ratio.
So... do we:
not even bother to answer the questions that are asked here?
Answer every question with a disclaimer statement about the 10%?
or just answer the question as helpfully as possible without judgement?
Whether this is bad coding or not, lavalamp at first stated "have you got any other ideas?"
That's when I entered the discussion. And afterwards he said "This is exactly what I asked for".
I really wish you wouldn't try to make me feel bad for trying to help.
:( k
I'm not trying to make you feel bad, really I'm not. But, I just wanted to point out to lavalamp that by using javascript in the onclick, and not providing a href for you link, the link will not work for anyone with javascript disabled. The benefit (a custom status after users click a link [benefit?] ) is vastly outweighted by the negative effect this will have of rendering the link useless for those without javascript. If you still plan to use javascript as the sole handler for the link, this would be a better way to write it to your page:
<script language="javascript" type="text/javascript">
document.write("<a onmouseover=\"window.status='Hi There';return true;\" onmouseout=\"window.status='Done';return true;\" onclick=\"document.location.href='hithere.html';\">Hi There</a>");
</script>With that method, the link will only show up for users who will be able to use it.
khaki
04-06-2003, 11:09 PM
That's cool. whatever.
But one word about these 10%
I have been on the internet almost from the beginning
(I watched Al Gore invent it. lol).
I've been working in the web-related field for over 3 years.
I have yet... EVER... to coma across ANYBODY that has
had javascript disabled.
That's NO ONE.
Not ONE.
So sure... there must be a 10% out there somewhere
(although we all know that stats lie).
But... there are still people with 12:00 flashing on their VCR
for years.
That doesn't mean that I have to pretend that it's 12:00 all
of the time, do I?
toungue partially in cheek...
:rolleyes: k
Nevermore
04-07-2003, 07:43 AM
I know about 30 people who browse without javascript, so that maes up for you not knowing any. Just so you don't feel left out.
David Harrison
04-07-2003, 07:44 AM
erm, I think that there's a problem with your script, because even after I deleted things like the spaces in between java script and everything else, the pointer didn't change and there was no border around the text.
khaki
04-07-2003, 08:30 AM
cijori wrote: I know about 30 people who browse without javascriptwell... that's a lot of people... but i need to ask:
What is the reason for this?
Intranet restrictions?
Disability limitations (n/a?)?
Or personal preference?
And if it's the latter... please do tell the reasoning benind this incredible
personal choice (seems to me like only choosing to drive on un-paved roads. lol).
But I'm seriously curious.
Anybody else out there who chooses to disable javascript (or knows of
anyone who does)?
drives on-road and off-road... by choice... (and because I can)....
;) k
khaki
04-07-2003, 08:45 AM
lavalamp wrote : erm, I think that there's a problem with your script...tell me about it... I've been catching flak about it ever since I answered
your question! LOL :eek:
But seriously.. I tested in Netscape7 and it worked as expected.
It didn't work on my buggy IE5.0 (but then again... very little does)
And I won't be back in the office until tomorrow or Wednesday to check it
on other browsers... so for now it's just my home machine that I can view it on.
I don't know what else to say lavalamp.
You asked for something...
I gave it a go...
But there is nothing more I can do at this point.
(and seriously... for what you are trying to accomplish... it's not worth the
hit that I have had to take for offering to provide you with a work-around.
I suggest that you use Pyro's script and not place too much emphasis on
the status bar. After all... you can disable that if it's really a problem for you...
for like security purposes, or something).
:rolleyes: k
Nevermore
04-07-2003, 08:47 AM
All but 6 of them are prevented from using javascript becuse they are disabled. Three are prevented because of restrictions put on them by their organisation. The other three are just weird I guess. (No offense meant, it's all in good humour)
Nevermore
04-07-2003, 09:04 AM
If you want to use href="" in the anchor tag, and have the status bar work, why not use this?
<html>
<head>
<title>Status Bar</title>
<script LANGUAGE="JavaScript">
function describe(text) {
window.status = text;
return true;
}
function clearstatus() {
window.status="Done";
}
</script>
</head>
<body>
<a HREF="hi.htm"
onMouseOver="describe('Hi There'); return true;"
onMouseOut="clearstatus();">
Hi There</a>
</body>
</html>
It won't disply the status change in Netscape 6.2, but it will allow everyone to navigate it.
David Harrison
04-07-2003, 09:12 AM
I'm sorry that you got so much stick for your script I honestly didn't mean for you to get put down it's just that sometimes I can be a little blunt and people sometimes take it te wrong way.
Please don't let this prevent you from answering any more of my posts. :)
khaki
04-07-2003, 12:18 PM
don't worry about it lavalamp.
I fuss.. kick and scream... push back.. and then it's all wonderful again.
These guys know that I love them... we just play rough sometimes
(with me usually finding myself on the short-end. But i've got 2 older brothers...
so i'm used to it).
And I know that you said that you didn't want code in the <head> of the page...
but cijori gave you a pretty solid option that you might want to consider.
Anyway... just one last thing that i would like to suggest:
Only use gimmicks and bells & whistles when necessary. I know that it's hard to
resist some of the things that you can do (or put on a page)...
but usually "less is more".
Just something for you to consider.
script on....
;) k
Nevermore
04-07-2003, 12:35 PM
Thanks, K, and sorry if it sounded like I was being rude earlier.
khaki
04-07-2003, 12:41 PM
it's all good ;)
('sept this effen snow! a foot expected in the NYC area by tonite! it's madness!!!)
David Harrison
04-07-2003, 12:52 PM
Oh my god, I don't believe you, you live in new york so you get a load of snow in winter and in summer you get a load of sun and you have central park and yet still you complain.
You should try living in England for a while we never get snow, (just some slush if were lucky) and it's cold all year round!!!
khaki
04-07-2003, 01:06 PM
it's April sweetie.
Time for flowers... not another crippling blizzard!
Central Parl looks nice covered in snow... but it's much more fun playing in
the grass of the Great Lawn and climbing on the giant snow-free rocks around
the lake. And skating at the fountain pretty much sucks in the snow. lol.
NY is a nicer playground when snow is NOT part of the equation (have you
ever walked in a city as big as NY with filthy snow and slush acting as barriers
to free movement? You would complain too... believe me.
So p-l-e-a-s-e... let me complain a little.
We've had more that enough snow already!
I need sunshine (i'm a summer baby!).
(and I've been to the UK. It was warn in October 97. I loved it!)
mind the gap...
;) k
Nevermore
04-07-2003, 03:49 PM
Lavalamp is right, we don't get any real weather at all in England. It's never really cold/hot/snowy/rainy etc, so there's no excitement.
khaki
04-07-2003, 04:31 PM
... now who's complaining? ;) k
Nevermore
04-08-2003, 05:43 AM
That would be me