PDA

View Full Version : What about statusbar-text when using window.location instead of anchors?


Ruben
03-23-2006, 10:33 AM
Hey all,

Right now I'm working on a website in which we're using alot of DIV's with onclicks on 'em as an alternative for anchors, seeing the W3C doesn't allow DIV's wrapped in anchors when you're using XHTML strict..

This is basically what we're doing:<div id="myLayer" onclick="window.location='http://www.actionscript.org';">
<p>
Actionscript.org is better then croisants with strawberry marmalade at 9 in the morning
</p>
</div>

But now my problem is that in contrary to what anchors do, onclicks don't seem to display my URL in the status-bar, what is the general way of dealing with this issue?


I'd be very pleased to see any input on this..

:rolleyes: - Ruben

jsebrech
03-23-2006, 11:41 AM
<div
onclick="window.location='http://localhost/';"
onmouseover="window.status='http://localhost/';"
onmouseout="window.status='';">
<p>test</p>
</div>
Note that this doesn't work for browsers where javascript status changes are disabled (firefox allows you to do this). The accepted practice is to use a tags so you have graceful fallback when javascript functionality is not available, but to restyle them into whatever you want.

Ruben
03-23-2006, 06:58 PM
jsebrech, thanks for your input first of all. However I already tried using the window.status thingie. Although W3C (http://www.w3.org) (or at least W3Schools (http://www.w3schools.com)) states it's supported in Firefox (http://www.w3schools.com/htmldom/dom_obj_window.asp), it only seems to be working for me in Internet Explorer.

Give it a shot and see if anybody gets a custom statusbar-text in Firefox (I'm using Firefox v1.5.0.1, if you post your findings please include your version-number):
http://www.w3schools.com/js/tryit.asp?filename=tryjs_statusbar

Aside from giving window.status custom values, has anybody got any ideas as how to achieve the anchorish display-the-URL-in-statusbar effect*?

:) - Ruben


* Sorry for the professional terminology ;)

jsebrech
03-24-2006, 07:43 AM
Yes, it works, but, go to Tools, Options, Content, then press the Advanced button next to Enable JavaScript, and see if "Change Statusbar Text" is checked. That's the problem with this technique, firefox lets you disable it. The default for this is for it to be turned on, so...

The only other way is to actually use anchor tags. I don't know of any other technique that changes the statusbar on div hover.

Ruben
03-25-2006, 01:07 PM
Ahh now I see, thanks for pointing out the prefs-thing. I now recall disabling it some months ago, hehe..

Regarding the anchor issue, it just doesn't really feel right to place 'em around DIV's, W3C doesn't like it, and I can see why.. It probably won't work in all browser either (DISCLAIMER: I haven't tested this though ;)).. but hey, thanks anyways for your input..

:) - Ruben

jsebrech
03-26-2006, 12:13 PM
You don't have to place them around div's, you can replace the divs with anchors, and change the display style rule to "block" to make them behave as divs. Modern browsers allow you to redefine the meaning of tags however you want.

Ruben
03-26-2006, 05:18 PM
Unfortunately, in our situation we would have to place them around the DIV's, if we'd use anchors that is..
But anyways, we'll just keep using window.status..

:) - Ruben