javascript onMouseOver Issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • naveenkongati
    New Member
    • Oct 2008
    • 52

    javascript onMouseOver Issue

    Hi,
    I am designing a calender which should display a relevent image onmouseover the link in a div.Suppose if a table has 5 links then 5 different images should be displayed in the the div.Kindly help me out.
    I have uploaded the files. Please go through it and suggest me about the modifications needs to be done as per the requirement.
    Thanks & Regards in advance
    Attached Files
    Last edited by naveenkongati; Dec 15 '09, 07:34 AM. Reason: adding code
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    use the CSS pseudo-class :hover

    Comment

    • naveenkongati
      New Member
      • Oct 2008
      • 52

      #3
      pls give a relevant link which has the code

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        a relevant link
        : )

        Comment

        • VipinKB
          New Member
          • Dec 2009
          • 3

          #5
          Hello Navin,

          Do the following in your code to make it work:

          1. Give id to image tag
          Code:
          <img [B]id="imgPIC"[/B]/>

          2. Use the below modified javascript function:

          Code:
          function showImg(picName){	
          	document.getElementById('PopUp').style.display='block';
          	document.getElementById('imgPIC').src = "pics/" + picName + ".jpg";
          }
          
          function hideImg(){
          	document.getElementById('PopUp').style.display='none';
          document.getElementById('imgPIC').src = "";
          }

          3. Call ShowImg function by passing date as paramter:
          Code:
          <a href="javascript:void(0)" onMouseOver="[B]showImg('5')[/B]"  onMouseOut="hideImg()">5</a></td>

          4. And the last and the most important thing... you need to rename your images as dates depending on what image you want to display for that date in DIV.
          So for e.g. republic day image should be renamed as 26.jpg
          and call showImg function as showImg('26').
          And this would display republic day image in DIV.


          Hope this helps.

          Thanks,
          Last edited by Dormilich; Dec 15 '09, 10:49 AM. Reason: Please use [code] tags when posting code

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            comments

            2. the element bearing the id "PopUp" must be block level element (p, div, li, …), otherwise your layout may break.

            3. onMouseOver (i.e. attributes in Camel Case) may not be supported by some browsers, use the lowercase attribute onmouseover instead. the same applies to the Javascript event properties (Element.onclic k, etc.)

            Comment

            • naveenkongati
              New Member
              • Oct 2008
              • 52

              #7
              First of all Many Many Thanks for your support. I have implemented your idea and made my entire application ready and it is working fine now.
              Another small issue related to the same application, now i am using absolute position for the DIV PopUp. Is it possible to make this as relatvie position according to the screen height & width?Also Dynamically change the DIV
              bgcolor.Is it possible?
              - Cheers

              Comment

              • Dormilich
                Recognized Expert Expert
                • Aug 2008
                • 8694

                #8
                Is it possible to make this as relatvie position according to the screen height & width?
                according to my resource, you can use percentage units.
                Also Dynamically change the DIV bgcolor. Is it possible?
                sure, change the backgroundColor property as desired.

                Comment

                • naveenkongati
                  New Member
                  • Oct 2008
                  • 52

                  #9
                  Now i am able to change background color property.Need some help on positioning DIV according to the mouse position.

                  Comment

                  • naveenkongati
                    New Member
                    • Oct 2008
                    • 52

                    #10
                    Now I could manage the position of the DIV also. Finally one more thing , can we provide multiple image type(.jpg/.gif) facility for this application. If it is what are the changes we need to make?

                    Comment

                    • Dormilich
                      Recognized Expert Expert
                      • Aug 2008
                      • 8694

                      #11
                      HTML does not care about image types. all it needs is a valid URL to the image.

                      Comment

                      • naveenkongati
                        New Member
                        • Oct 2008
                        • 52

                        #12
                        I agree with your point. In this case we are hardcoding ".jpg". If I want to include .gif/.bmp what change need to be done in js file

                        Comment

                        • Dormilich
                          Recognized Expert Expert
                          • Aug 2008
                          • 8694

                          #13
                          include the file extension in the picture’s name (aka. pass the complete file name)

                          Comment

                          Working...