javascript - hover effect on a tablet (i.e. iPad)? - Stack Overflow

I'm the processing of redesigning a website that uses hover effect on a button (like button images

I'm the processing of redesigning a website that uses hover effect on a button (like button images changes when you put your mouse over it and when you click it, it goes to a different page).

Now that works fine if you're on a a desktop/laptop puter. But on a tablet, the hover/onmouseover effect does not work. On a tablet, when clicking the button image, it changes briefly and then immediately goes to a new page.

What are methods and techniques where a website can detect if a visitor es from a tablet or not? Then would it be possible to switch to a tablet CSS version? Or, are there tablet framework (i.e. Modernizer?) that can help with this process?

I'm the processing of redesigning a website that uses hover effect on a button (like button images changes when you put your mouse over it and when you click it, it goes to a different page).

Now that works fine if you're on a a desktop/laptop puter. But on a tablet, the hover/onmouseover effect does not work. On a tablet, when clicking the button image, it changes briefly and then immediately goes to a new page.

What are methods and techniques where a website can detect if a visitor es from a tablet or not? Then would it be possible to switch to a tablet CSS version? Or, are there tablet framework (i.e. Modernizer?) that can help with this process?

Share Improve this question asked Nov 13, 2011 at 20:46 tester2001tester2001 1,0733 gold badges14 silver badges25 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 5

Touch devices don't have a hover event and there is no way to emulate the user interaction that might initiate it. Make sure that there is no critical functionality assocaited with hover events (most just do highlighting) so there is no loss of functionality if the device doesn't have it. Browser sniffing by UA string is a flawed strategy - you must update it every time a new device es along or the string changes for an existing device. Great if you're into high prices for maintenance, but not if you're the one paying for it.

You could identify the iPad (or mobile device) simply by checking the User-Agent parameter of the browser.

In PHP for example you could do something like:

if( strstr($_SERVER['HTTP_USER_AGENT'],'iPad') ) { // Add custom iPad CSS }

If you want to get it further you could use WURFL (http://wurfl.sourceforge/)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744577180a4581813.html

相关推荐

  • javascript - hover effect on a tablet (i.e. iPad)? - Stack Overflow

    I'm the processing of redesigning a website that uses hover effect on a button (like button images

    2天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信