Web Analytics Made Easy -
StatCounter Different functions for Anchor and Image - CodingForum

Announcement

Collapse
No announcement yet.

Different functions for Anchor and Image

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

  • Different functions for Anchor and Image

    Hi,

    Is this possible:

    Code:
    <script src="scripts/myfunctions.js" type="text/javascript" ></script>
    <a href="javascript:function1()" ><img src="images/some_image.png" onmouseover="function2()" onmouseout="function3()" onclick="function4()" ></a>
    Sorry if this is a newbie question, but in my case, the anchor function seems to work, but the onmouseover etc. don't seem to.

    Thanks for help in advance,

    Ajay.

  • #2
    Can we have a link to your page? You could use firebug, to find the errors in your scrip, if any.
    Digitalocean Cloud Hosting (Referral link - get $10 free credit) Fameco

    Comment


    • #3
      Thanks for the reply.

      You may see the actual page here:

      http://www.ninesec.com/newweb/index.html

      Ajay.

      Comment


      • #4
        Let me explain the problem I'm facing. If you check out the page at the link, the mouseover & mouseout work fine on the Nav Bar buttons on top of the page. But if I apply similar logic on the left hand menu buttons, it doesn't seem to work. Moreover, with only the Nav Bar & the tabSwitch functions in the functions file, both Firefox & IE worked as expected. But after adding new functions, the tabSwitch & NavBar functions work ok in FF, but not in IE, while the functions for menu dont work in either.

        Thanks again for help.

        Comment


        • #5
          Fix the errors in your markup first, see http://validator.w3.org/check?uri=ht...Inline&group=0
          Enclose all attribute values in double quotes.

          FF treats your markup like
          Code:
          <img 2)="" onclick="mouseClick(hm," onmouseout="mouseOut(hm," onmouseover="mouseOver(hm," id="hmb2" alt="Our Successes" src="images/v1/home_menu_b2.png"/>
          Digitalocean Cloud Hosting (Referral link - get $10 free credit) Fameco

          Comment


          • #6
            Hey thanks for the wakeup call. This really helped me in finding out the grey areas of my code. I did make some headway getting things to work out with FF. But IE still refuses to behave, inspite of getting the XHTML page to validate. I guess, I need to get to debug from the last good working code with IE. Will keep things posted. Thanks again.

            Ajay.

            Comment


            • #7
              This is what I see when I go to your site:

              Code:
              <a href="ninesecstory.html"><img src="images/v1/home_menu_b1.png" alt="Ninesec Story" id="hmb1" [COLOR="Red"]onmouseover=mouseOver(hm, 1)[/COLOR] [COLOR="Red"]onmouseout=mouseOut(hm, 1)[/COLOR] [COLOR="Red"]onclick=mouseClick(hm, 1)[/COLOR] /></a><br />
              <a href="successstories.html"><img src="images/v1/home_menu_b2.png" alt="Our Successes" id="hmb2" onmouseover=mouseOver(hm, 2) onmouseout=mouseOut(hm, 2) onclick=mouseClick(hm, 2) /></a><br />
              <a href="contactus.html"><img src="images/v1/home_menu_b3.png" alt="Contact Us" id="hmb3" onmouseover=mouseOver(hm, 3) onmouseout=mouseOut(hm, 3) onclick=mouseClick(hm, 3) /></a><br />
              Note the stuff, marked in red... it needs to be enclosed in quotes. (For every link, I just marked one, but I'm sure you can see it on the others too.) There are still some warnings in regards to the validity of your HTML... except for the ones that I point out up there. Fix those, see how that works.
              Last edited by Eldarrion; Apr 9, 2009, 02:55 PM.
              The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

              How to ask smart questions?

              Comment


              • #8
                Thanks guys. The validation process helped a lot to identify the errors, not just of the XHTML, but otherwise also. Fixed them (although, I'm still not 100% satisfied with the resulting code that I've cooked up, but that's for some other day) and now the pages pass the XHTML validation. Things are working as expected in FF, Safari. BUT, as expected, IE is creating problems. I've uploaded the corrected files. If you can please help me once again to sort out issues with IE. While earlier IE used to spew out Object Expected and other Blahs, now it remains silent. The Top NavBar functions work fine, but on the other menus the functions (onmouseover, onmouseout & onclick) are not doing anything. The same functions work fine in FF & Saf. Thanks again for your help.

                Ajay.

                Comment

                Working...
                X