我有一个现有的悬停菜单,可以在我测试的所有浏览器和设备上正常运行。在这个菜单中,我添加了一个用于登录和密码的输入框,现在当使用Safari触摸ipad / iphone上的密码字段时,它会触发菜单关闭。此行为也发生在IE(桌面)中。
要在IE中修复此问题,我使用了以下代码:
<script type="text/javascript">
$(document).ready(function(){
$(".subnav-container select").mouseleave(function(event){
event.stopPropagation();
});
});
</script>
添加此修复程序后,问题仍然存在于ipad / iphone上的Safari中。但是,它可以在ipad / iphone上的Chrome中正常运行。
我已尝试过针对移动版Safari的此修复程序,但它无效:
<script type="text/javascript">
document.addEventListener('touchstart', function ( e ) {
e.preventDefault();
var touch = e.touches[0];
alert(touch.pageX + " - " + touch.pageY);
}, false);
</script>
我尝试过touchenter,touchleave,touchstart但没有使用如何应用修复触摸屏设备问题的经验。
我的基本html如下:
<div data-async-loaded="loaded" data-gadget="menu.gadget.MyMenuNav" data-load="preloaded">
<nav class="menu">
<div class="tier0">
<div class="shop facet nav-section" data-subnav="tab1" data-nav-tracking="tab1">
<a href="javascript:void(0)">
<span class="font-family--platform button-font-size--small facet-label">
LOGIN
<span class="arrow-down text--medium-light-grey">
</span>
</span>
</a>
</div>
</div>
<div class="tier1">
<div data-subnav="tab1" class="subnav tracking is-hidden" data-nav-tracking="tab1">
<div class="subnav-container">
<div class="subnav-section">
<div class="subnav-item l-w6 visual-format">
<form name="login" action="http://football21.myfantasyleague.com/2013/login" method="post">
<input type="hidden" name="LEAGUE_ID" value="24779" />
<table align="center" cellspacing="1" class="homepagemodule report" id="welcome"><caption><span>Welcome</span></caption><tbody><tr><th colspan="2">Guest</th></tr>
<tr class="oddtablerow"><td class="inputlabel">Login As:</td>
<td><select size="1" name="FRANCHISE_ID">
<option value="0000">Commissioner</option>
<option value="0001">UR4BIDN</option>
<option value="0002">NIKE TEAM B</option>
<option value="0003">NIKE TEAM C</option>
<option value="0004">Franchise 4</option>
<option value="0005">Franchise 5</option>
<option value="0006">Franchise 6</option>
<option value="0007">Franchise 7</option>
<option value="0008">Franchise 8</option>
<option value="0009">Franchise 9</option>
<option value="0010">Franchise 10</option>
<option value="0011">TRADEA</option>
<option value="0012">TRADEB</option>
</select></td></tr>
<tr class="eventablerow"><td class="inputlabel">Password:</td><td><input name="PASSWORD" type="password" size="10" /> </td></tr>
<tr class="oddtablerow"><td align="center" colspan="2"><input type="submit" value="Login" /> </td></tr>
</tbody></table></form>
</div>
</div>
</div>
</div>
</div>
</nav>
</div>
答案 0 :(得分:0)
script type="text/javascript">
document.addEventListener('touchend', function ( e ) {
e.preventDefault();
e.stopPropagation();
var touch = e.touches[0];
alert(touch.pageX + " - " + touch.pageY);
});
</script>