开发者

how to disable hyperlink browsing from an Html editor?

开发者 https://www.devze.com 2022-12-27 10:13 出处:网络
how do I disable browsingto a http link from a Html editor. I have a vb.net web form with a html editor, when I add a hyperlink to the html editor, for example my application website for instance

how do I disable browsing to a http link from a Html editor. I have a vb.net web form with a html editor, when I add a hyperlink to the html editor, for example my application website for instance

http://myapplication/myloginpage.aspx

When I run and click the link I can browse my application from inside the Html Editor which is so weird.It should open the link in a new window. How do I stop this from happening. This is an Intranet application. And the component f开发者_运维技巧or Html Editor is of TMS.

Or is there any Javascript code available where I can deactivate the link from an HtmlEditor, i mean when i add any hyperlink it should be not be activated , or no should be able to browse it from inside the HtmlEditor ?


You would have to visit each link in javascript and add an onclick event that cancels the link. But when you save your HTML that you are editing you'll want to remove that from each link!

<a href="http://www.google.com" onclick="return false">Click me</a>

You can do it with something like this (untested):

var linkElements = document.getElementById("documentInEditor").getElementsByTagName("a");

for( var i=0; i<linkElements.length; i++ ) {
    linkElements[i].setAttribute("onclick", "return false");
}


you could prevent the link from doing anything with javascript.

in jquery it would go something like this:

$('a').click(function(){
    $(this).unbind();
    return false;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消