林很確定我的語法這個錯誤,因爲腳本只適用於字符串匹配「視頻」,如果字符串有「字」音頻「它被忽略。的 「#」 重定向的 「../../../index.html」 不工作的值。多個字符串與indexOf匹配()
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>
srcTag.indexOf( '視頻')> -1 || srcTag.indexOf('Audio')> -1 –
嘗試使用此部分的絕對網址: window.location ='../../../index。html' – bygrace
它需要是一個相對的URL,因爲它將在本地運行,並且無法知道用戶驅動的字母是什麼。 – Blainer