Im pretty sure my syntax this wrong because the script only works if the string matches “Video”, if the string has the “word “Audio” it is ignored. Also since the href tags have a value of “#” the redirect for “../../../index.html” doesnt work.
js
var ua = navigator.userAgent.toLowerCase();
var isIE8 = /MSIE 8.0/i.test(ua);
if (isIE8) {
$('a').click(function () {
var srcTag = $(this).find('img').attr('src');
if (srcTag.indexOf('Video' || 'Audio') > -1) {
if (confirm('Download Safari? \n\n http://apple.com/safari/download/')) {
window.location = 'http://apple.com/safari/download/';
} else { window.location = '../../../index.html';}
} else {
alert('no match');
}
});
}
html
<a href="#"><img src="Video/000_Movies/assets/005_CCC_Jesus_Story_80x60.jpg" />test1</a>
<a href="#"><img src="Audio/000_Movies/assets/006_GSP_Gods_Story_80x60.jpg" />test2</a>
<a href="#"><img src="Media/000_Movies/assets/002_God_Man_80x60.jpg" />test3</a>
It’s far shorter to turn this into a regular expression.
On a side note, please don’t do what you’re attempting to do. Asking users to download Safari when they’re using Internet Explorer 8 is doing a disservice to the Internet, as well as to that user.
As for redirecting the domain to another location, you should use
.preventDefault()to keep the browser from following the link:Again, please don’t actually do this. Nobody wants to be that guy, and when you tell users to download another browser, you’re being that guy.