How does the Link objects's disabled poperty works internally?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Revathi Balakrishnan
    New Member
    • Jun 2008
    • 40

    How does the Link objects's disabled poperty works internally?

    Hi All
    If i use the below code i am able to disable the style sheet of a document.
    But i wanted to understand how this disabled property works internally? becaues in html normally if we do any change that will be reflected only after refresh. but here the stylesheet change of a html document is achieved with out any refresh. i want to understand how this achieved. Can any one help me?


    Code:
    <html>
    <head>
    <link rel="stylesheet" type="text/css" 
    id="style1" href="try_dom_link.css" /><script type="text/javascript">
    function disableStyle()
      {
      document.getElementById("style1").disabled=true
      }
    </script>
    </head>
    <body><form>
    <input type="button" id="button1" onclick="disableStyle()" 
    value="Disable style sheet" />
    </form></body>
    </html>
    Thank you in Advance :)
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    what you reallly do here is setting a javascript-property of an element. this is instantly rendered but this would be even the case when you would use:

    [CODE=javascript]node_ref.setAtt ribute('disable d', 'disabled');[/CODE]
    you could even set the className property of the node to another css-class and the changes are made during runtime ... and of course: just for the runtime. that's one of the purposes of javascript ... adding runtime-behaviour to your page.

    as you see there are different ways to achieve a disabled-state for an element, and you should decide for only one to avoid difficult debugs when mixing the attribute-seeting with property-settings ... in case you used the attribute method you have to remove the attribute to reenable the field again ... when using the property you may set it to false ...

    i hope this helps you?

    kind regards

    Comment

    • Rsmastermind
      New Member
      • Sep 2008
      • 93

      #3
      This is something complex question but verbally,When the page is loaded fully now the page is reserved for the browser and for the events of the javascripts.

      Like If you have worked on the servers the jars and wars are created to reserve the java files and web files any change from outside means in the code will not effect until the server started again.So using event handlers that is in client side
      we can change the dynamic properties.Like what you had done in your codes.
      disable is an attribute to each field .

      When you run the script you are doing it dynamically not permanently.But any change in the CSS file will be permanent change.

      I hope you will be having some idea after reading the above things.

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        Originally posted by Rsmastermind
        ... So using event handlers that is in client side
        we can change the dynamic properties.Like what you had done in your codes.
        disable is an attribute to each field . ...
        there is a difference between attributes and js-properties of a dom-node ... as i mentioned in my previous post ... so it is good to use the words in this case with more care. attributes are the node's html/xml-attributes ... properties are the javascript-properties of the object ... there are differences in their use and mixing something could lead to some confusion ...

        kind regards

        Comment

        • Rsmastermind
          New Member
          • Sep 2008
          • 93

          #5
          Ok fine as I had written in the very begining that this is explained verbally.So I tried it verbally not caring much more about the terminology.

          But thank you for the suggestion I will take care of that.

          Comment

          • gits
            Recognized Expert Moderator Expert
            • May 2007
            • 5390

            #6
            i understand that ... i just wanted to point that out for readers in the future :)

            Comment

            • Revathi Balakrishnan
              New Member
              • Jun 2008
              • 40

              #7
              i understood that this stylesheet disabling property is achived with javascript's dynamic behaviour.[if i misunderstood correct me]

              gits and RSmastermind thank you for your help.

              Comment

              • Rsmastermind
                New Member
                • Sep 2008
                • 93

                #8
                Most welcome .
                This is the way we learn and share the knowledge.
                More you ask more you learn.

                Comment

                Working...