按钮在移动设备上不起作用,但在PC引导程序上起作用

按钮在移动设备上不起作用,但在PC引导程序上起作用

问题描述:

我创建了一个内部具有链接的引导按钮.看起来像这样:

I created a bootstrap button that has a link inside. Which looks like this:

当您将鼠标悬停在上面时:

When you hover on it:

这是按钮内的代码:

 <div class="s-8"><button type="button" onClick="javascript:location.href = 'administration.php';">Administration</button></div>

登出按钮:

<div class="s-4"><button type="button" onClick="javascript:location.href = 'logout.php';">Logout</button></div>

此按钮在PC(IE,SAFARI,FireFox,Chrome,Opera)浏览器上正常工作(将我带到管理页面,但在移动设备上不起作用.

This button works fine on the PC(IE, SAFARI, FireFox, Chrome, Opera) browser(takes me to the administration page, but it doesn't work on the Mobile devices.

我对注销按钮做了同样的事情,并且在PC和移动设备上都可以正常工作.我现在很困惑.

I did the same thing for the logout button, and it works fine on PC and Mobile Devices. I am now puzzled.

问题可能是您正在使用onClick事件,该事件不会在移动设备上注册(因为您没有单击-点击).

The issue may be that you're using the onClick event which won't register on a mobile device (as you don't click - you tap).

此答案说明了如何使用将在移动设备上运行的"touchstart"事件.

This answer explains how to use the "touchstart" event which will work on a mobile.

https://stackoverflow.com/a/22015946/2619909