javascript window status isn't working right

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

javascript window status isn't working right

Post by m3rajk »

i have a script that gives a blurb about the person when you run over a link to them. however, the problem is on one server it only does the firs and last. on the other it's doing all but one. i can't find errors with the javascript and am unsure of why i am getting this behaviour.

demo site:
http://24.91.157.113/findyourdesire/des ... fn=desired

deployment site:
http://www.findyourdesire.com/desire.ph ... fn=desired
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

You should notice that the links that are giving you problems have the html entity for the ' character within the mouseover attribute e.g. they contain ' if you replace these with \' (note the leading slash) all will be well.
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

thank you. i didn't realize that javascript needed \& for & .. i know i have & for & in other places in javascript. and that works right. thank you for the explanation.
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

It is not that the & character requires escaping in javascript, it is specifically that you had the HTML entity for the ' character. This entity is converted back to it's actuall character prior to the javascript code working. so something like.....

Code: Select all

onmouseover="window.status='Let's see what happens';"
...is actually interpreted as.....

Code: Select all

onmouseover="window.status='Let's see what happens';"
As you can see, the entity has been converted back to it's actual character, and as the single quote encapsulates the window status command you end up with an error.

Given that then this.....

Code: Select all

onmouseover="window.status='Let\'s see what happens';"
...is actually interpreted as.....

Code: Select all

onmouseover="window.status='Let''s see what happens';"
With the single quote within the window status command correctly escape all is well.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Also, make sure you return true when you change the status

Code: Select all

onmouseover="window.status='Let''s see what happens';return true;"
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

Yep, I should have added that for completness, for what it's worth I also prefer to add the onmouseout command too which will clear the status bar when you move off the link....

Code: Select all

onmouseover="window.status='Let''s see what happens'; return true;" onmouseout="window.status=''; return true;"
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

just out ofcuriosty, since it's related, i have some buttons on a nav bar on other pages that use onmouseover and onmouseout. will that catch someoen tabbing or do i need onfocus/pnblur as well for that (and conversly, would onfocus/onblur worl for scrolling the mouse over?)
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

onfocus and onblur won't work for buttons - those are events generally triggered formfields. A button/graphic simply never receives focus.
You will need to use onmouseout and onmouseover for that.
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

ok. i had that. if you go and check the page code for the index, the navigation bar. i had onmouseover and onmouseout set to switch the button for the finduser submit button, but there's a issue with that would never work. still not sure why... :(

any help on finding a way to do that?

http://www.findyourdesire.com
Post Reply