Hi guys I can't seem to find the exact thing I am trying to do, and being a javascript amateur I can't seem to wrangle it. Basically... I have this script attached to various elements on my page
$(document).ready(function() {
$("h1, h2, h5, .class1, .class2 #image1").click(function () {
window.open('https://www.linkdesktop.com');
});
});
and what I want to do is: IF on mobile device THEN switch www.linkdesktop.com TO www.linkmobile.com
Is this possible, do I do it based on screen size or using some sort of mobile detect script?
Answers appreciated, thanks a lot.
Ok so thanks for the answer
so perhaps somthing like this?
var userAgent = window.navigator.userAgent;
$(document).ready(function() {
if( (Android|webOS|iPhone|iPad|iPod|BlackBerry).test(navigator.userAgent) ) {
$("h1, h2, h5, .class1, .class2 #image1").click(function () {
window.open('https://www.linkmobile.com');
});
}
else {
$("h1, h2, h5, .class1, .class2 #image1").click(function () {
window.open('https://www.linkdesktop.com');
});
}
});