how can i disable a javascript from an html page

Discussion in 'Programming' started by visitorjavascript, Oct 7, 2009.

  1. #1
    Hello there

    i have a page that has a javascript and I need it to display some stuff, but I also would like to have a link that when you click on it, it will disable that javascript (without taking you to another page)

    I hope this makes sense

    Thanks
     
    visitorjavascript, Oct 7, 2009 IP
  2. oxidati0n

    oxidati0n Peon

    Messages:
    744
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    So, you want to remove javascript from a page essentially using.. JavaScript?
    Doesn't really make sense, nope.
     
    oxidati0n, Oct 7, 2009 IP
  3. visitorjavascript

    visitorjavascript Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    pretty much, sorry if i didn't explain myself properly, basically what i would need it is a button to enable/disable the javascript in that page

    I hope this is more clear

    Cheers
     
    visitorjavascript, Oct 7, 2009 IP
  4. yohanip

    yohanip Well-Known Member

    Messages:
    350
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    108
    #4
    did you use jquery?if so use the jquery attr class to remove your onclick events on all of your tags
    baasicly you are not disabling the javascript, you just remove the onclick handler on your specific areas
     
    yohanip, Oct 10, 2009 IP
  5. Sapphiro

    Sapphiro Well-Known Member

    Messages:
    1,242
    Likes Received:
    61
    Best Answers:
    0
    Trophy Points:
    175
    #5
    A simpler method might be to use a PHP session.

    By default you have that block of javascript, then when you click the link.. use PHP code to destroy session on the spot. (but requires refreshing of the same page), if you don't want the page to refresh, then you'll need to do abit more, by having to use AJAX together with PHP.


    Hope this is useful to you. :)
     
    Sapphiro, Oct 10, 2009 IP
  6. oxidati0n

    oxidati0n Peon

    Messages:
    744
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Exactly what I was thinking. You're more likely to get a better result using PHP as it will remember the user's specific credentials for that request, making it annoyance-free.
     
    oxidati0n, Oct 11, 2009 IP
  7. benson647

    benson647 Peon

    Messages:
    27
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    You can set disable property of button to false on form load event of javascript.
     
    benson647, Oct 11, 2009 IP