Friday, 13 May 2016

javascript - Redirect Using jQuery




So I'm using jquerymobile for an app I'm creating. I have a link that if all the validation passes I'd like to go through, but if something fails I'd like to redirect.



In the jquery something like this. Since it is jquerymobile the link will be a new div on the same index.html page - if that helps.




$(#link).click(function(){  
if(validation_fails) link_elsewhere;
else return true;
}

Answer



You can use the window.location to redirect a browser:



https://developer.mozilla.org/en/DOM/window.location


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...