如何使用Java禁用超链接 [英] How do i disabled hyperlink using Javascript
本文介绍了如何使用Java禁用超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
专家,
我想使用具有跨浏览器支持的Java脚本禁用超链接.
您的回答将不胜感激!
谢谢,
Imdadhusen
Hi
Expert,
I would like to disable hyperlink using java script, with cross browser support.
Your answer will be appreciated!:thumbsup:
Thanks,
Imdadhusen
推荐答案
要禁用超链接,请定义看起来已禁用的超链接CSS类,然后更改href属性以导航回到页面顶部.
在服务器端,您还必须关闭该元素的自动回发.
因此,这里是CSS和JavaScript,以使超链接显示为禁用,并导航至页面顶部:
CSS:
To disable a hyperlink define a hyperlink CSS class that looks disabled and then change the href property to navigate back to the top of the page.
Server-side, you''ll also have to turn off the auto-postback of that element.
So, here''s the CSS and JavaScript to make the hyperlink appear disabled, and navigate to page top:
The CSS:
.disabledLink
{
color: #333;
text-decoration : none;
cursor: default;
}
javascript:
The javascript:
function disablelink(linkID)
{
var hlink = document.getElementById(linkID);
if(!hlink)
return;
hlink.href = "#";
hlink.className = "disableLink";
}
调用传递您的超链接ID的javascript函数
call the javascript function passing your Hyperlink Id
下面的示例通过在第一个语句中添加一个额外的"return false"来更改链接.这将阻止任何操作,但也可以删除"return false"部分以再次启用它.
http://radio.javaranch.com/pascarello/2005/05/17/1116355421179.html [^ ]
祝你好运!
The example below changes the link by adding an extra "return false" as a first statement. This will prevent any action but also makes it possible to remove the "return false" part to enable it again.
http://radio.javaranch.com/pascarello/2005/05/17/1116355421179.html[^]
Good luck!
看看这个技巧: [
Have a look at this tip: Disable all ''links'' on the page via Javascript[^]
这篇关于如何使用Java禁用超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文