PDA

View Full Version : allowing users to choose whether to use onmouseover or onclick


canadianjameson
09-27-2004, 07:10 PM
i currently have a dynamically reloading div which has text loaded into it based on which link users have their mouse over. pretty simple concept. you can see it here:
www.enviromark.ca/english/products.html

a buddy of mine is strong in his beleif that while snazzy, this is unproffesional and hinders the usability of this page. the owner of the page whom i designed it for likes it (but he's easily amused :D ). I see both points as being valid, so i want to comprimize.

can i modify a script (i'll post code later if its even possible) to switch from onmouseover="..." to onclick="..." i.e i give the users a "click here to switch to onclick" link, which would switch it.

i dont even know if this is even feasable... just figured i'd throw it out to the smarter people

Garadon
09-27-2004, 10:34 PM
you can set both event handlers to send a boolean(to avoid the browsers boring event objects)

onmouseover=do(false,....

onclick=do(true,....

then on the "click here to apply click" link

<a href="#" onclick="applyClick=!applyClick;"

and in the script block

applyClick=false;

function do(eventBool,...){
if(eventBool==applyClick){
"show stuff"
}
}


conceptual code :). Btw I saw your code and having multiple function numbered to be different is usually in my opinion a bad idea. you should be able to send the number into an unnumbered function which would then be applyable to all the uses of the others.

canadianjameson
09-27-2004, 10:56 PM
*picks self off floor*

i talk a big game, but in reality i have no idea how to apply your suggestion. any chance you could give me a hand with the code modification? i can throw in things here and there but on the whole i couldnt apply your suggestion on my own :(

the code is a script i was given, i didnt write it myself. any modifications to it that you see as good by all means do & i'll use the upgraded script

EDIT: i do see how it could work (after a second look). i may not need that much help, just a little more. should i post the code?