点击按钮或链接时,得到转向页面的url值

解决方案 »

  1.   

    既然都是跳转页面
    那里直接在跳转的页面获取他的href不就行了吗?
      

  2.   

    var str = document.body.innerHTML;
    然后用正则表达式匹配搜索
      

  3.   

    to gu1dai(异域苍穹.百年飞行) ?怎么找?我倒是希望点哪个的就获得哪个的。
      

  4.   

    document.onclick = function(e)
    {
        e = event||e; e=e.srcElement || e.target;
        alert(e.tagName); //这个 e 对象就是触发页面 onclick 事件的那个对象,你得到它之后再做相关的分析
    }
      

  5.   

    比如说:点击了超级连接,那么e.tagName就是a
            点击了button    那么e.tagName就是input
    然后根据tagName来获取,也挺烦的
      

  6.   

    对于<a href="">好弄,但是其它的链接怎么弄呢?
      

  7.   

    问题他还有调用函数里的URL,这个通过事件就不容易知道了.
      

  8.   

    document.onclick=function(e){
    reg = /http\:\/\/[^\"]+/g;
    alert(event.srcElement.outerHTML.match(reg));
    }
    这样就可以了
      

  9.   

    to aniude(阿牛的乜乜):test.htm代码如下:1.<a href='http://www.baidu.com'>test</a>
    <SPAN onClick='window.open("http://www.baidu.com","Microsoft","height=400,width=400")'>Microsoft</SPAN>
    2.<input onclick="javascript:location.href='http://www.baidu.com';" type=button value="test">
    3.<input onclick="javascript:location.replace('http://www.baidu.com')" type=button value="test">
    4.<input onclick="test()" type=button value="test">
    <script>
    function test(){location.href='http://www.baidu.com';}
    </script>
    5.<form action="http://www.baidu.com" method=post><input id=tt type=submit value="test"></form>

    <script>
    document.onclick=function(e){
    reg = /http\:\/\/[^\"]+/g;
    document.write(event.srcElement.outerHTML.match(reg));
    }
    </script>
    -----------------------
    测试结果对于1,2能取得正确结果,3,4,5都不行。
    另外很大的问题是当点击页面的任何其他地方时也输出了结果,希望是点击页面的其他地方,不要输出任何东西。