我想創建一個按鈕,它將在使用javascript的新文檔中顯示瀏覽器的詳細信息。我已經在這裏搜索和w3schools,我很難過!我真的很新的JavaScript,所以任何建議,非常感謝。謝謝!Javascript - 在新文檔中顯示瀏覽器的詳細信息
<html>
<head>
<script type="text/javascript">
function docOpen()
{
document.open();
document.write(browserDetails);
}
function browserDetails() {
var x = navigator
document.write("CodeName=" + x.appCodeName)
document.write("<br />")
document.write("MinorVersion=" + x.appMinorVersion)
document.write("<br />")
document.write("Name=" + x.appName)
document.write("<br />")
document.write("Version=" + x.appVersion)
document.write("<br />")
document.write("CookieEnabled=" + x.cookieEnabled)
document.write("<br />")
document.write("CPUClass=" + x.cpuClass)
document.write("<br />")
document.write("OnLine=" + x.onLine)
document.write("<br />")
document.write("Platform=" + x.platform)
document.write("<br />")
document.write("UA=" + x.userAgent)
document.write("<br />")
document.write("BrowserLanguage=" + x.browserLanguage)
document.write("<br />")
document.write("SystemLanguage=" + x.systemLanguage)
document.write("<br />")
document.write("UserLanguage=」 + x.userLanguage)
}
</script>
</head>
<body>
<form>
<input type="button" onclick="docOpen()" value="Get Browser Details">
</form>
</body>
W3Schools的建議(見【規範】警告不良行爲,比如'document.write'(http://www.w3.org/TR/html5/webappapis:
我在做一個工作的小提琴html的#文件撰寫%28%29))。我建議避免這兩個。 – Oriol
謝謝Oriol。我的大學教授給我提供了document.write作爲例子。這對於班級來說並不好。 lol –