下面的代码,点击链接文档标题为何不修改?
<!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>

解决方案 »

  1.   

    貌似你的js里写的return false? 这样还会执行什么啊!!
      

  2.   

    document.title = a
    改成
    document.title = a.innerHTML;
      

  3.   

    <a href="2.html" onclick="return setTitle(this.innerText)">22222222222222</a>
      

  4.   

    只有服务器控件,才需要放回一个bool型吧
      

  5.   

    <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;
          }
      </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>
      

  6.   

    <!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);
    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>
      

  7.   


    <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>
      

  8.   

    改成9楼那样,title会显示你要的效果。
      

  9.   

    楼上的没错  加一个 <title>****</title>
    标签就OK了   但是你链接的地址要是正确的否则就标题是 无法显示网页
      

  10.   

    <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>
      

  11.   

    正确答案应该是
    <a href="#" onClick="test(this.parentNode.innerText)">this.parentNode.innerText
      

  12.   

    最后修改为,不知道这个href为什么不能直接用,真奇怪<!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);
              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>
      

  13.   

    把this.href 改为 this.innerText 刚不是都说了么大家~~~~~~
      

  14.   

    <!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">
          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>
      

  15.   

    ie6会自动为href属性的值加上全路径吧,所以不一致。