asp中,使用js打开别的网址注意点

  在我的asp项目中,有这样一段js代码:

  <script language="javascript">

    var div = document.createElement("div");

    div.style.cssText = "height:300px; width:400px; left:200px; top:200px;"

    document.body.appendChild(div)

    div.onclick = function(){

      window.location = "www.sohu.com";

    }

  </script>

  结果,单击该div时,却定位到项目中当前目录下:http://localhost/xxx/www.sohu.com,奥结果是死活打不开啊。

经过调研后才发现问题所在,原来正确的js代码应该是:

      window.location = http://www.sohu.com;

posted @ 2010-01-17 13:32  弹着钢琴设计  阅读(251)  评论(0编辑  收藏  举报