我想创建一个按钮,它将在使用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 –