views:

270

answers:

2

Hello , 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 for 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 ?

A: 

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;
}
Haroldo
thank you , how can I use Jquery with TMS Html Editor ?
ahmed
A: 

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");
}
Matthew Lock
ok....thank you...but my case is different. I have an Html editor and the uswer can add any link and save. So I need to do something to link with HtmlEditor, so that the user if entered any link should be deactivated. thank you for your support once again.
ahmed
That's what the above would do, deactivate any link the user entered. You just need to work out what document/id HtmlEditor stores its page that's being edited in.
Matthew Lock