有很奇怪的。它看起来像在If语句之后,它停止的脚本。该页面具有通过单击按钮调用的javascript函数。如果IE上的浏览器,我会做点什么。否则,我关闭该页面。我把警报声明来测试它。但警报从未解雇。有人会告诉我我的代码会出现什么问题。之后如果声明什么都不会在javascript中触发
还有就是我的按钮调用该函数:
<input class="btn" id="btnClose" onclick="javascript:openFile();" type="button" value="Close" name="btnClose" />
有JavaScript函数:
function openFile() {
var url = 'file://' + document.getElementById("hdURL").value;
//alert('Open File' + url);
var location = document.getElementById("hdURL").value;
////http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
if ((/*@[email protected]*/false || !!document.documentMode) ||(!isIE && !!window.StyleMedia))
{
alert('IE');
//do something
window.self.close();
}
alert('test'); //never fire
closeWindow();
}
''不something' - 这是应该是一个评论?如果是这样,它应该是'//做些事情'。 – Santi
我看不到'isIE'在哪里定义。看看你的浏览器控制台。你在那里看到错误吗? – Amy
@Amy这是一个很好的观点。看看[引用的问题OP](http:// stackoverflow。com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser)为他们的'if'逻辑,接受答案使用'var isIE =(...逻辑...) '。 OP复制+粘贴该逻辑并将其用作上述问题中他们的'if'语句的第一个条件,而不是像引用的答案那样将其转换为var'isIE'。 – Santi