Web Analytics Made Easy -
StatCounter Advice Needed For A Quick Dip Into Javascript - CodingForum

Announcement

Collapse
No announcement yet.

Advice Needed For A Quick Dip Into Javascript

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Advice Needed For A Quick Dip Into Javascript

    I gave up using Dreamweaver a couple of years ago, when I discovered CSS.

    But I remember that it's very easy to create scripts which allow for visibility-based behaviours, such as 'show/hide' on a mouse-hover. Lots of it rather good for rollovers and changing the apparent contents of a text box, etc. All this can be done in a point'n'click fashion, without knowing any code.

    What I'd like to know is how, once the script were created, I could implement it, along with my stylesheet and lean HTML code, to work as a unit.

    I'm guessing I could copy&paste the script that Dreamweaver creates, into a blank document and then link it into the HTML document, somehow.

    But what are the rules for doing this? What is the proceedure for implementing Javascript, into HTML (other than it being in the markup itself)? Does Dreamweaver actually make valid Javascript? Ideally, I'd like to eventually end up writing my own, from scratch. Seeing the code form in Dreamweaver's code-view might actually help me to learn it's syntax.

    What do you think? Any thoughts on this are welcome.

    Hope this makes sense. Many thanks.

    Doctor V
    Last edited by Doctor_Varney; Apr 14, 2009, 12:41 PM.
    Definition: Computer rage is a heightened physiological response with associated feelings of anger and frustration[1] resulting from using a computer or other complex electronic device. It may result in the physical assault of the computer or similar item.[2] Computer use often leads to verbal abuse and occasionally physical violence towards the object.[3] Computer rage may be caused by distress due to a hardware or software problem which the enraged person is unable to correct.

  • #2
    Hmm.. If I understand your question you're asking for something that removes the text if you hover over it?

    You could try learning about the onMouseOver and onMouseOff JavaScript functions. JS isn't really my thing..

    Also, using CSS, it also works. Say you have this:

    Code:
    <html>
    <head>
    </head>
    
    <body>
    <p>hi</p>
    </body>
    </html>
    just a simple HTML page.

    now, you can add an ID to "hi", and assign a ":hover" to it (I might be loosing you now.. Have you heard of a:hover?) to create this:

    Code:
    <html>
    <head>
    <script type="text/css">
    p #hi:hover {
    color: white;
    }
    </script>
    </head>
    
    <body>
    <p id="hi">hi</p>
    </body>
    </html>
    NOTE: This doesn't work in all browsers.

    If I lost you on anything, just reply and I'll walk you through it.

    Regards,
    "DLA"
    Always Use a DOCTYPE!
    Always Use * {margin: 0; border: none; padding: 0;} in the top of your CSS stylesheet.
    Always Use only CSS for layout; never (X)HTML.
    Always Have fun while coding!

    Comment


    • #3
      Hi DarklightA

      Thanks for the reply. You're bang on with my intentions - yes, it's to take advantage of the mouseover/out functions. Yes, I'm familiar with a:hover; the last thing I used it for, being a toggle for visibility, as well as a:link color. I'm just after a little bit more... I wish that I could use pure CSS to cause change in an element, outside of the one that carries the hover.

      For instance: (ideally)

      Code:
      a:hover{visibility-of-#thatdivoverthere:hidden}
      Whereas normally, you can only cause the hover function to occur in the link it's applied to. I want to be able to use it to control other elements. Javascript offers this very behaviour.

      Perhaps it's possible with CSS and I've just missed it.

      You get the idea?

      Cheers,

      Doctor V
      Last edited by Doctor_Varney; Apr 14, 2009, 09:38 PM.
      Definition: Computer rage is a heightened physiological response with associated feelings of anger and frustration[1] resulting from using a computer or other complex electronic device. It may result in the physical assault of the computer or similar item.[2] Computer use often leads to verbal abuse and occasionally physical violence towards the object.[3] Computer rage may be caused by distress due to a hardware or software problem which the enraged person is unable to correct.

      Comment


      • #4
        In the method you show, it can be done, but I'm drawing a blank right now as I try to do it even though I've implemented it myself. (It's bedtime)

        Here's a horrible example:
        Code:
        <style type='text/css'>
        div:hover #a{color:red}
        div:hover #b{color:yellow}
        </style>
        </head>
        <body>
        <div>
                <span id="a">Hello</span><span id="b">there</span>
        </div>
        </body>
        Last edited by drhowarddrfine; Apr 14, 2009, 10:47 PM.
        Is IE9 a modern browser?
        IE9 is at least 2 years behind the modern web.

        Comment


        • #5
          Originally posted by drhowarddrfine View Post
          In the method you show, it can be done, but I'm drawing a blank right now as I try to do it even though I've implemented it myself. (It's bedtime)

          Here's a horrible example:
          Code:
          <style type='text/css'>
          div:hover #a{color:red}
          div:hover #b{color:yellow}
          </style>
          </head>
          <body>
          <div>
                  <span id="a">Hello</span><span id="b">there</span>
          </div>
          </body>
          I think that could look quite horrible, with just the right background... I'm thinking a nice lime green...
          Definition: Computer rage is a heightened physiological response with associated feelings of anger and frustration[1] resulting from using a computer or other complex electronic device. It may result in the physical assault of the computer or similar item.[2] Computer use often leads to verbal abuse and occasionally physical violence towards the object.[3] Computer rage may be caused by distress due to a hardware or software problem which the enraged person is unable to correct.

          Comment

          Working...
          X