I want a browser detection onClick
on a button and if the result is NO
. The page will redirect to the given url. The button is a submit
type in a form. I can make it a browser check but when It alerts. The redirect is not go - still submit form.
HTML
<button type="submit" onClick="isChrome()";>submit</button>
Script
function isChrome() {
$.browser.chrome = /chrom(e|ium)/.test(navigator.userAgent.toLowerCase());
event.preventDefault();
if(!$.browser.chrome){
alert('Please use only Google Chrome!');
window.location="http://www.google.com/chrome/";
return false;
stop();
}
}
FIDDLE HERE : http://jsfiddle.net/nobuts/g89k68ge/
if you don't want to submit the form, you can simply create a button instead. Why bother to cancel the submit function