为什么IE8无法使用document.title =“test title”更改文档标题;document.title问题ie8
3
A
回答
2
以下为我工作的IE8。但是我确实得到了ActiveX安全弹出窗口,所以也许你的IE8没有设置为提示这些问题,只是拒绝脚本。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Test</title>
<script type="text/javascript">
function changeTitle() {
document.title = 'Foobar';
}
</script>
</head>
<body onload="changeTitle()">
</body>
</html>
+0
document.title确实工作,该功能没有解雇感谢。 – 2011-03-09 21:12:08
0
发现这一点: http://support.microsoft.com/kb/296113
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JAVASCRIPT">
function runTest()
{
var s ="We should set this as the new title"
var mytitle = document.createElement("TITLE");
mytitle.innerHTML = s;
alert(s);
document.documentElement.childNodes[0].appendChild(mytitle);
}
function fix()
{
var s = "Now we change the title";
alert(s);
document.title = s;
}
</SCRIPT>
</HEAD>
<BODY>
<input type="button" value="Problem" onclick="runTest()"/>
<input type="button" value="Workaround" onclick="fix()"/>
</BODY>
对我来说,这是在IE的作品9,8,7
也许你不打电话给你的功能,还是有一些东西,不是作品。
document.title必须工作!
1
真的吗?使用document.title = 'Foo Bar';
一直为我工作。你的脚本是否正在执行?
尝试document.title = ...
前推搡这一权利:
alert('I work.');
如果你没有得到一个警告框,你的脚本甚至没有运行。
Facebook可以做到这一点,所以必须有一种方法。我需要使我的网站在IE浏览器上工作如此:( – 2011-03-09 20:41:16