I have an iPhone app where I have many links which allows user to call or email.
<a href="tel:12345678912">Call Us</a>
<a href="mailto:support@help.com">Email Us</a>
As I am preveting default on every <a>
using jQuery.
var after = function(e, sender, action) {
if (href.indexOf("tel:") === 0 || href.indexOf开发者_如何学Python("mailto:") === 0) {
return true;
}
// more of my code
};
if (window.Touch) {
$("a").bind("touchstart", function(e1) {
e1.preventDefault();
var that = $(this);
var moved = false;
that.bind("touchmove", function(e2) {
moved = true;
});
that.bind("touchend", function(e3) {
that.unbind("touchmove");
that.unbind("touchend");
if (!moved) {
after(e3, this, "touchend");
return false;
}
});
});
}
else {
$("a").live("click", function(e) {
e.preventDefault();
after(e, this, "click");
});
}
Shouldn't it work?
preventDefault means you are preventing the link from executing.
From your code it looks like you are stopping links from being clicked so you can use a nicer touch event. So, you'll need to load the page on success.
Not 100% sure how your code works, but it looks like if (!moved) {
is when the link is tapped and you want the page to change. So just add window.location = this.href
精彩评论