Safari移动忽略防止默认 [英] Safari mobile ignoring prevent default

查看:130
本文介绍了Safari移动忽略防止默认的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



它在桌面上按预期工作,其中的链接不会无效 t访问href,但在Safari浏览器中,它似乎忽略它并访问链接,就好像没有加载JavaScript一样。



它显然加载了javascript,因为google maps的标记和信息窗口正在加载罚款。

链接的代码是这样的:

  $( '更多信息窗口,.infowindow H3 a ')的生活(' 点击',函数(E){
e.preventDefault();

/ *从外部html文件加载内容* /
$('#content .content')。html('< p class =loading>< img src =images / icons / loader。 gifalt =载入内容...>< / p>');
$('#content .content')。load($(this).attr('href')+' #content> *',function(){

显然,和b obs。



有没有其他人有任何问题或知道解决方案?



谢谢



Dave。

解决方案

b $ b

  e.preventDefault(); 

追加到该函数的结尾处

  return false; 

然后点击< a> 元素将不会重定向到任何地方。


I am using e.preventdefault() on a link which is in an infowindow on google maps.

It works as expected on the desktop where the link doesn't visit the href but on safari it seems to ignore it and visits the link as if no javascript is loaded.

It is clearly loading the javascript because google maps along with lots of markers and the info windows are loading fine.

The code for the link is this:

$('.infowindow .more, .infowindow h3 a').live('click', function(e) {
    e.preventDefault();

    /* Loading content from external html file */
    $('#content .content').html('<p class="loading"><img src="images/icons/loader.gif" alt="Loading content..."></p>');
    $('#content .content').load($(this).attr('href') + ' #content > *', function() {

Obviously the code carrys on from here with other bits and bobs.

Has anyone else had any issues or knows a solution for this?

Thanks

Dave.

解决方案

Instead of using

e.preventDefault();

append at the end of that function

return false;

Then clicked <a> element will not redirect to anywhere.

这篇关于Safari移动忽略防止默认的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆