下面的代码,点击链接文档标题为何不修改?
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>dfadfddsfsa</title>
<script type="text/javascript">
//document.title = 'aaaaaaaaaaa';
function setTitle(a) {
alert(a);
document.title = a;
return false;
}
</script>
</head>
<body scroll="no" id="mainbody">
<form id="form1" runat="server">
test
<input type="text" />
<input type="text" />
<input type="button" value="aa" id="xxx" />
<input type="button" value="bb" class="borderImage" />
<a href="1.html" onclick="return setTitle(this.href)">11111111111111</a>
<a href="2.html" onclick="return setTitle(this.href)">22222222222222</a>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>dfadfddsfsa</title>
<script type="text/javascript">
//document.title = 'aaaaaaaaaaa';
function setTitle(a) {
alert(a);
document.title = a;
return false;
}
</script>
</head>
<body scroll="no" id="mainbody">
<form id="form1" runat="server">
test
<input type="text" />
<input type="text" />
<input type="button" value="aa" id="xxx" />
<input type="button" value="bb" class="borderImage" />
<a href="1.html" onclick="return setTitle(this.href)">11111111111111</a>
<a href="2.html" onclick="return setTitle(this.href)">22222222222222</a>
</form>
</body>
</html>
改成
document.title = a.innerHTML;
<head runat="server">
<title>dfadfddsfsa</title>
<script type="text/javascript">
//document.title = 'aaaaaaaaaaa';
function setTitle(a) {
alert(a);
document.title = a;
}
</script>
</head>
<body scroll="no" id="mainbody">
<form id="form1" runat="server">
test
<input type="text" />
<input type="text" />
<input type="button" value="aa" id="xxx" />
<input type="button" value="bb" class="borderImage" />
<a href="#" onclick="setTitle('bb')">11111111111111</a>
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>dfadfddsfsa</title>
<script type="text/javascript">
//document.title = 'aaaaaaaaaaa';
function setTitle(a) {
alert(a);
var ss=a.split("/");
document.title = ss[ss.length-1];
return false;
}
</script>
</head>
<body scroll="no" id="mainbody">
<form id="form1" runat="server">
test
<input type="text" />
<input type="text" />
<input type="button" value="aa" id="xxx" />
<input type="button" value="bb" class="borderImage" />
<a href="1.html" onclick="return setTitle(this.href)">11111111111111</a>
<a href="2.html" onclick="return setTitle(this.href)">22222222222222</a>
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>dfadfddsfsa</title>
<script type="text/javascript">
//document.title = 'aaaaaaaaaaa';
function setTitle(a) {
document.title = a;
}
</script>
</head>
<body scroll="no" id="mainbody">
<form id="form1" runat="server">
test
<input type="text" />
<input type="text" />
<input type="button" value="aa" id="xxx" />
<input type="button" value="bb" class="borderImage" />
<a href="javascript:void(0)" onclick="setTitle('11111111111111')">11111111111111</a>
<a href="javascript:void(0)" onclick="setTitle('22222222222222')">22222222222222</a>
</form>
</body>
</html>
标签就OK了 但是你链接的地址要是正确的否则就标题是 无法显示网页
//document.title = 'aaaaaaaaaaa';
function setTitle(a) {
alert(a);
var ss=a.split("/");
document.title = ss[ss.length-1];
return false;
}
</script>
<a href="#" onClick="test(this.parentNode.innerText)">this.parentNode.innerText
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>dfadfddsfsa</title>
<script type="text/javascript">
//document.title = 'aaaaaaaaaaa';
function setTitle(a) {
alert(a);
var ss = a.split("/"); var url = ""; for (var i = 0; i < ss.length; i++) {
if (i == ss.length - 1) {
url += ss[i];
}
else {
url += ss[i] + "/";
}
}
alert(url);
document.title = url;
return false;
}
</script>
</head>
<body scroll="no" id="mainbody">
<form id="form1" runat="server">
test
<input type="text" />
<input type="text" />
<input type="button" value="aa" id="xxx" />
<input type="button" value="bb" class="borderImage" />
<a href="1.html" onclick="return setTitle(this.href)">11111111111111</a>
<a href="2.html" onclick="return setTitle(this.href)">22222222222222</a>
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>dfadfddsfsa</title>
<script type="text/javascript">
function setTitle() {
document.title = document.getElementById("link1").innerHTML;
}
</script>
</head>
<body scroll="no" id="mainbody">
<form id="form1" runat="server">
test
<input type="text" />
<input type="text" />
<input type="button" value="aa" id="xxx" />
<input type="button" value="bb" class="borderImage" />
<a href="#" onclick="setTitle()" id="link1">11111111111111</a>
</form>
</body>
</html>