Results 1 to 10 of 10

Thread: Disabling a anchor tag using javascript

  1. #1
    Join Date
    Aug 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up Disabling a anchor tag using javascript

    hi,

    I will explain my need pls give me a solutuion.

    I got Some two or three anchor tags in a jsp page.While onclick of one <a href= ..> tag it is calling one of the javascript function some background process is going on.so upto that process it should not possible for the user to click other <a href=..> tags.

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    <a href="javascript:void(0)">BLAHBLAH</a>

  3. #3
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Code:
    <a href="#" onclick="return false">BLAH BLAH BLAH</a>
    - Mike

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    If no appropriate href can be given, a button should be used instead.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Aug 2006
    Location
    Dartmouth, NS, CANADA
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    He only wants to disable it temporarily.

    You'll need a flag to keep track of whether or not the link should be active. Get your background process to set it to false until it's finished processing.

    var Link_Enabled_Flag = false; // disable links - background process changes this to true when it's done

    function Check_Link_Enabled{ return Link_Enabled_Flag; }

    Then in your link just have <a href="wherever.com" onclick="return Check_Link_Enabled()">

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    function Check_Link_Enabled(){ return Link_Enabled_Flag; }
    But yes, that's so.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Brackets are important
    - Mike

  8. #8
    Join Date
    Aug 2006
    Location
    Dartmouth, NS, CANADA
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Red face

    oops... my bad :()

  9. #9
    Join Date
    Apr 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question how to enabled or disabled anchor tag

    hai..i too want the code that..i have 10 anchor tags in a jsp page.if i click one anchor tag and the remaining 9 anchor tags must be disabled.is it possible in jsp's using javascript.please help me..iam waiting for ur reply..reply me soon

  10. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,167
    Thanks
    44
    Thanked 3,240 Times in 3,201 Posts
    Blog Entries
    12

    Default

    Yes. Just do as outlined in the above posts.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •