Topic: 怎样中断超链接<a href>?

  Print this page

1.怎样中断超链接<a href>? Copy to clipboard
Posted by: morphine
Posted on: 2005-11-28 10:23

问题如下:<a href = "www.sohu.com" onclick="confirmFunction()">
在confirmFunction中有一个confirm提示,确定之后正常转向href的链接sohu;
取消之后就不转向sohu
请问怎样实现
Thanks in advance!

2.Re:怎样中断超链接<a href>? [Re: morphine] Copy to clipboard
Posted by: morphine
Posted on: 2005-11-29 08:26

请大家帮忙想想办法,谢谢了!

3.Re:怎样中断超链接<a href>? [Re: morphine] Copy to clipboard
Posted by: ntshenwh
Posted on: 2005-11-29 09:03

hi,
page code:
<a href = "#" onclick="confirmFunction()">SOHU</a>

javascript:
function confirmFunction()
{
if ( window.confirm("Are you sure?") )
{  
window.location.href="http://www.sohu.com";    
}
}

4.Re:怎样中断超链接<a href>? [Re: morphine] Copy to clipboard
Posted by: morphine
Posted on: 2005-11-29 09:32

谢谢,这个方法确实可以解决
再问一下,那个window.location是怎么使用的,我在网上没有找到确切的方法,论坛里也没看到

5.Re:怎样中断超链接<a href>? [Re: morphine] Copy to clipboard
Posted by: morphine
Posted on: 2005-11-29 09:33

另外,我还找到了另外一种解决我这个问题的方法,如下:

6.Re:怎样中断超链接<a href>? [Re: morphine] Copy to clipboard
Posted by: morphine
Posted on: 2005-11-29 09:33

另外,我还找到了另外一种解决我这个问题的方法,如下:

<a href="www.sohu.com" onclick='javascript:if (confirm("确定要访问SOHU?")) {""} else {return false}'>www.sohu.com</a>

7.Re:怎样中断超链接<a href>? [Re: morphine] Copy to clipboard
Posted by: ntshenwh
Posted on: 2005-11-29 09:38

hi,
好方法!
另外 window.location 等等都是 window对象的属性或方法,包括 window.document 等等.这部分你要查看html资料或到 vs msdn 6.0 中可以找到相应的帮助.

8.Re:怎样中断超链接<a href>? [Re: morphine] Copy to clipboard
Posted by: morphine
Posted on: 2005-11-29 09:41

好的,我会去找些相关的资料
谢谢ntshenwh


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923