location.hrefジャンプテスト

3150 ワード

 

<script type="text/javascript">   

function ToUrl(x){   

      location.href=x;

}   

script>   

<a href="javascript:;" onclick="javascript:ToUrl('http://www.baidu.com');">location.href 1a>   

<a href="javascript:void(0);" onclick="javascript:ToUrl('http://www.baidu.com');">location.href 2a>   

<a href="javascript:void(0);" onclick="javascript:ToUrl('http://www.baidu.com');return false;">location.href 3a>   

<a href="#" onclick="javascript:ToUrl('http://www.baidu.com');">location.href 4a>   

<a href="###" onclick="javascript:ToUrl('http://www.baidu.com');">location.href 5a>  

chromeテスト、4、5は失効します.
転載先:https://www.cnblogs.com/cssfirefly/p/6595792.html