Page 1 of 1
javascript window status isn't working right
Posted: Tue Jan 20, 2004 4:55 pm
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
Posted: Tue Jan 20, 2004 6:08 pm
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.
Posted: Tue Jan 20, 2004 7:25 pm
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.
Posted: Wed Jan 21, 2004 6:03 am
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.
Posted: Wed Jan 21, 2004 6:18 am
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;"
Posted: Wed Jan 21, 2004 6:23 am
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;"
Posted: Wed Jan 21, 2004 6:43 pm
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?)
Posted: Thu Jan 22, 2004 3:13 am
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.
Posted: Thu Jan 22, 2004 10:02 am
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