I have seen a lot of websites about replace in JavaScript
, I am new to JavaScript
, I appreciate some help?
This JavaScript
code didn't work when I tried it in JSFiddle:
window.onload = function() {
if (navigator.userAgent.indexOf('iPhone|iPod|iPad') != -1) {
$("a[href$='iPhone']").attr("href", function() {
return this.href.replace("iPhone", "IIIphone");
});
} else {
$("a[href$='iPhone']").attr("href", function() {
return this.href.replace("iPhone", "Android");
}
}
}
}
and my HTML
is
<a href="http://www.mypage.com?iPhone-type=iPhone">The 1 link</a>
<a href="http://www.mypage2.com?iPhone-type=iPhone">The 2 link</a>