How to disable link or td?

Hi people actually i started a thread in HTML forum by thinking that it would have solution …

[QUOTE=kvijayhari;3280749]i want to disable a link and it should not redirect to the specified page.

also i want to disable a <td> that means whatever the <td> contains should also be disabled…

what should i do ??

i tried disabled for the link and it produces a disable like view in IE7 but when clicked it goes to the target page and in firefox and mozilla the disable has no effect…

pls help to sort this out[/QUOTE]

[QUOTE=AutisticCuckoo;3282075]This really belongs in the JavaScript forum, but here’s something to give you an idea. Let’s assume that the link you want to disable has an ID equal to ‘foo’.

var a = document.getElementById("foo");
a.className = "disabled";
a.onclick = function() {return false};

By setting the class to ‘disabled’, we can easily style the ‘disabled’ link with CSS:

a.disabled {color:#999; cursor:default}

[/QUOTE]

can you people pls help with a sample code to disable a link or a <td>…

Post the code you have written so far. Or, hire a web programmer. This isn’t a forum for free web programming services. This is a forum for helping people learn javascript.

7stud, that’s a bit harsh, isn’t it?

Viju, you’ll have to provide more detail about what your markup looks like as well as how and when you want these things to be disabled.

If you can’t figure out what to do from the code snippet I posted, there’s a risk that this is going to be too complicated for you. In that case, you might want to heed 7stud’s advice and bring in someone to help you with the coding.

Another option is that you learn some basic JavaScript and DOM so that you can do this yourself. That’s beyond the scope of this forum to provide, however.

Another option is that you learn some basic JavaScript and DOM so that you can do this yourself. That’s beyond the scope of this forum to provide, however.

Learning Javascript/DOM is precisely the scope of this forum!

:lol: * mike pokes tommy in the ribs and giggles *

kvijayhari, give us a link to your page and we will be glad to help you :slight_smile:

… maybe …

just kidding! :lol:

Where’s my coffee!!!

Indeed … that was poorly phrased by me. I meant that we cannot educate someone from zero knowledge to JavaScript guru within a single thread. :slight_smile:

I’ll let you get away with that since it’s Valentine’s Day and all. :rofl:

:lol:

Hey, you look good in green. Congrats!

Thanks, Mike! :tup:

hi guys ,

   i've sorted it out and it's working very nicely. The concept which AutisticCuckoo gave me helped me to solve it.:)

i haven’t posted that code because i thought that it would be a very nice little code or portion which can be writtten of easily by the experts. and i thought it not necessary to post all my code because a it’s nothing to see there. :rolleyes:

thank you :slight_smile: :slight_smile:

yes u r right , as i noted earlier i thought it would be a very silly question i’ve asked to post with code and all other details.

i’m slowly going thru the javascript and dom … so i’ll post more and more appropriately.

thanks guys:)

Simply overwrite the link target with the link itself.

function linkkill(linker)
{
var aname=“a”+Math.random();
linker.id=aname;
linker.href=“#”+aname;
}

This code should change the link to an anchor pointing to itself.