HTML - Image Mapping
I just started learning HTML for myself, and have come across something very specific that confuses me.
When filling the "coords" just how can one find EXACT coordinates of the pixels needed for each point? I understand how image mapping itself works, but when I was going to make one myself, I was lost as to how I would have the accuracy I needed. There's so many pixels of course I can't just eye them lol. But I wondered if there was a way, so I could make them as precise as needed. Thnx Similar TutorialsWow, this site has been SUPER helpful to me So, now that I have my background color and image and all of the fun stuff, I would like to do background mapping. I have the code for the mapping but I do not know how to post it in conjunction w/what background code I am already using. This is the code that I am currently using: <body style="background-image:url(http://i17.photobucket.com/albums/b9...osition:center center;background-attachment:fixed> <body bgcolor="FFFF66"> ----------------------------------------------- And below is the mapping code that I got from another site (I haven't put any of my info into it, yet) I just need to know about the placement of the code.......... Can anyone help ----------------------------------------------- <img src ="planets.gif" width ="145" height ="126" alt="Planets" usemap ="#planetmap" /> <map id ="planetmap" name="planetmap"> <area shape ="rect" coords ="0,0,82,126" href ="sun.htm" target ="_blank" alt="Sun" /> <area shape ="circle" coords ="90,58,3" href ="mercur.htm" target ="_blank" alt="Mercury" /> <area shape ="circle" coords ="124,58,8" href ="venus.htm" target ="_blank" alt="Venus" /> </map> Hi Friends I got a problem when using image mapping in html using dream weaver.While we map some area in the image it automatically gives co-ordinates in the code and if the window size is changed, the mapping area changed.How to give relative position to the image map not depending on the co-ordinates. Hoping that i will get reply from u soon............... Regards, Padmaja.M. I tried to map an image, but it only partially worked. This is my code HTML Code: <img src="images/about-20.jpg" USEMAP="#choices"> <map name="choices"> <area shape="RECT" coords="0,93,0,70" href="gallery.html"> <area shape="RECT" coords="0.93,98,168" href="bestposters.html"> <area shape="RECT" coords="0,200,93,272" href="create.html"> </map> The mapping only worked for the third part, the 'create.html' Here is the site this is on: www.demotivationalpictures.com Any ideas why it didn't map the first two parts of the picture? So, I'm a complete amateur at HTML, and need help. <html> <img src="http://i43.tinypic.com/35k0r3c.png" width="1350" border="0" usemap="#imap_55" > <map id="imap_55" name="imap_55" > <area shape="rect" coords="9,12,94,95" alt="P2W360's Profile" title="P2W360's Profile" href="http://live.xbox.com/en-US/MyXbox/Profile?GamerTag=P2W360"> </map> </html> * { outline: none; -moz-outline: none; } .clear{ clear:both; height:1px; margin-bottom:-1px; } body{ background: #000 url(http://i43.tinypic.com/35k0r3c.png) center center fixed no-repeat; {block:IfBackgroundImage} background: #000 url('{image:Background}') top left fixed; {/block:IfBackgroundImage} color:#fff; font-size:11px; font-family: "Lucida Grande", "Lucida Sans", "Lucida Sans Unicode", Geneva, Verdana, sans-serif ; text-shadow: #000 0px 1px 0px; } WHY WON'T IT WORK EDIT: I'm using tumblr if that's any use. Hi, My latest web site developement was very heavy loaded with images, in fact probably 90% of the site is images. I decided to use image maps on most of the pages and was wondering if there are any downsides to image mapping apart from not being to good for the search engines. If anyone has any comments or advice from past experieince i would really appreciate the info CC_DESIGN I have a problem in implementing image mapping in mouse-over image. Please help in solving this problem. The code which is working for image mapping Code: <html> <head> <title>Untitled Document</title> </head> <body> <img src="images/planetgroup.jpg" alt="Planets" usemap=#planetmapping border=0></img> <map name="planetmapping"> <area shape="rect" coords="559,0,612,60" href="http://www.yahoo.co.in/"> <area shape="rect" coords="504,0,561,60" href="http://www.yahoo.co.in/"> <area shape="rect" coords="449,0,507,60" href="http://www.yahoo.co.in/"> <area shape="rect" coords="395,0,451,60" href="http://www.yahoo.co.in/"> <area shape="rect" coords="340,0,397,60" href="http://www.yahoo.co.in/"> <area shape="rect" coords="292,0,342,60" href="http://www.yahoo.co.in/"> <area shape="rect" coords="236,0,297,60" href="http://www.yahoo.co.in/"> <area shape="rect" coords="194,0,238,60" href="http://www.yahoo.co.in/"> <area shape="rect" coords="148,0,196,60" href="http://www.yahoo.co.in/"> <area shape="rect" coords="1,0,49,60" href="http://www.google.co.in/"> <area shape="rect" coords="47,0,103,60" href="http://www.yahoo.co.in/"> <area shape="rect" coords="99,0,150,60" href="http://www.yahoo.co.in/"> </map> </body> </html> But The code after using in mouse-over which needs help Code: <html> <body> <div style="position:absolute; left: 200px; top: 180px; z-index:1"><img src="images/solarsystem.gif" alt="Solar System" height="60" onMouseOver="this.src='images/planetgroup.jpg'; usemap=#planetmapping" onMouseOut="this.src='images/solarsystem.gif';"></img></div> <map name="planetmapping"> <area shape="rect" coords="559,0,612,60" href="http://www.yahoo.co.in/"> <area shape="rect" coords="504,0,561,60" href="http://www.yahoo.co.in/"> <area shape="rect" coords="449,0,507,60" href="http://www.yahoo.co.in/"> <area shape="rect" coords="395,0,451,60" href="http://www.yahoo.co.in/"> <area shape="rect" coords="340,0,397,60" href="http://www.yahoo.co.in/"> <area shape="rect" coords="292,0,342,60" href="http://www.yahoo.co.in/"> <area shape="rect" coords="236,0,297,60" href="http://www.yahoo.co.in/"> <area shape="rect" coords="194,0,238,60" href="http://www.yahoo.co.in/"> <area shape="rect" coords="148,0,196,60" href="http://www.yahoo.co.in/"> <area shape="rect" coords="1,0,49,60" href="http://www.google.co.in/"> <area shape="rect" coords="47,0,103,60" href="http://www.yahoo.co.in/"> <area shape="rect" coords="99,0,150,60" href="http://www.yahoo.co.in/"> </map> </body> </html> Hey guys. I'm having a little trouble manipulating this image the way I want to. Here's my goal: I have a large image of the city of Louisville and additional images of that are identical, but have certain regions/neighborhoods highlighted. I'm wanting to have the image displayed in full and when the user hovers over a certain area, or part of the city, then the image with that area highlighted is displayed until onMouseOut. Here's what I have so far, the onmouseover doesn't seem to be working at all. Code: <html> <head><title>xxxx</title> <script language="JavaScript"> <!-- function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function mouseOver() { document.louisville.src = "images/Louisville_Downtown.JPG"; } function mouseOut() { document.louisville.src = "images/Louisville_Full.JPG"; } //--></script> </head> <body onLoad="MM_preloadImages('images/Louisville_Full.JPG','images/Louisville_Audubon.JPG', 'images/Louisville_Downtown.JPG','images/Louisville_Poplar_Newburg.JPG','images/Louisville_Shively.JPG','images /Louisville_ValleyStation.JPG')"> <center> <FONT size = "5"><B>Louisville Neighborhoods</B></FONT> <br> <img id="pic" src="images/Louisville_Full.JPG" alt="" usemap="#louisville" border="0" name="louisville"> <map id="louisville" name="louisville"> <area shape="rect" coords="0.000, 0.000, 7.000, 7.000" onmouseover="mouseOver()" onmouseout="mouseOut()"> </map> </center> </body> </html> The coords aren't setup correctly yet, but I'm just trying to get it to do something. Any help would be appreciated. -Tyler I have been experimenting with a new page setup and I've got a problem I just can't figure out. Anyway, I have an image mapped for navigation on the left-hand side of the page/table. It seems to work fine and everything is fine up to this point. Now I am trying to add another navigational map to the image at the top of my page and when I code it, the map seems to work fine, but either the images or the table gets thrown off and I just can't figure out why it's doing it or how to fix it. The code for the top image map is as follows: <body bgcolor="#000000" text="000000" topmargin="0" leftmargin="0"> <div align="center"> <table border="0" cellpadding="0" cellspacing="0" width="600" height="770"> <tr> <td width="600" height="150" colspan="3"> <img src="http://vance.thebams.org/junk/images/new images/topbg.jpg" usemap="#topmap" border="0"></td> <map id="topmap" name="topmap"> <area shape="rect" coords="51,98,107,119" href="index.html"/> <area shape="rect" coords="121,99,218,119" href="bookkeeping.html"/> <area shape="rect" coords="232,99,357,119" href="payroll.html"/> <area shape="rect" coords="371,99,457,119" href="web.html"/> <area shape="rect" coords="474,98,607,119" href="personal.html"/> <area shape="rect" coords="621,98,710,119" href="contact.html"/> </map> </tr> The page that shows exactly how I want the page to look without the map at the top of the page can be seen here. When I add the image map at the top of the page it ends up looking like this. You'll notice that the area around the pen's tip is off. If anyone has any suggestions as to what I did wrong and how to fix it, I would greatly appreciate it. Thanks, Vance Hey there, first post on this forum so nice to meet you all.. I have a problem with placing an image that has been image mapped. Its either, I have the image in the right place but without the image maps, or in the wrong place with the image maps.. headwrecker! My girlfriends brother persuaded me to box him off a proper band myspace and with the persuasive power of a crate of lager i agreed.. so here is what i have scrapped together... http://www.myspace.com/thecommitments52 (nb: this is only a test page for myself...) You see the main image header and the three white tabs: add, message and comment.. I am using a div style to keep the image header where I want it... Here is a seperate piece of html away from the main piece of html with the image mapped and ready to go: Quote: <map name='Map1'> <area shape='polygon' href='http://friends.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendId=423424063' alt='' title='' coords='543,181 668,145 679,178 553,218' /> <area shape='polygon' href='http://messaging.myspace.com/index.cfm?fuseaction=mail.message&friendID=423424063' alt='' title='' coords='502,252 745,236 747,274 503,287' /> <area shape='polygon' href='http://comment.myspace.com/index.cfm?fuseaction=user.viewProfile_commentForm&friendID=423424063' alt='' title='' coords='455,297 694,359 687,395 446,332' /> </map> <img border='0' usemap='#Map1' src='http://h1.ripway.com/palefountain/png.png' alt='' /> here is the main HTML i insert into the myspace section: Code: <style> {!- make room at bottom of div.profileWidth -!} div.profileWidth table {margin-bottom:518px !important;} {! apply banner as bkgd image !} div.profileWidth{background-image:url(http://h1.ripway.com/palefountain/png.png)!important; background-position:center bottom !important; background-repeat:no-repeat !important;} {!- reverse -!} table.rail, .i, .i i.x {display:none;} </style> <style> body { font-size: 1px; line-height: 1px; font-family: Verdana, Arial, sans-serif; background-color:transparent; background-image:url(http://h1.ripway.com/palefountain/newbg.gif ); background-attachment: fixed; background-position: bottom left; background-repeat: no-repeat; margin-top:10px; padding-left: 0px; } p {margin: 0px 0px 1em 0px; font-family: Verdana, sans-serif !important} a, a:link, a:visited {color:ff0000; text-decoration: none;} a:hover {color:52f6f5; text-decoration: none} img {border: none} br {line-height: 10px;} u {text-decoration: none; } table table table br { line-height:15px; } * html table table table.latestBlogEntry br { line-height:0; } form {border-width:0px;background-color:none;} input {background-color:transparent !important} body>div {margin-left: 10px;} table { border:1px solid red;} table, tr, td, table table, table table td {border-width:0px; background-color: transparent;} table table table td {background-color:transparent;margin:0px;padding:0; vertical-align:top ! important;} * html table table table td {padding: 0 0px 0px 0px;} table table table table {border-width:0px; background-color: transparent; margin:0px; padding:0px; background-image: none;} table table table table table{ border-color:ffffff;} table table table table td {padding:0px 0;margin:0px; } table table table table table td { padding:0 0px 0 0;} table table table { margin:0px; max-width: 435px; width: 100% !important; padding: 0 12px 14px 12px; } * html table table table { padding:0;} body td table, body div table {margin-top: 0;} font {color:386093;font-size:10px} a font:hover {color:53f9e1} a.navbar:link, a.navbar:visited {color:ff0000} a.navbar:hover {color:53f9e1} table tr td table tr td font {display: inline;} table tr td table a.navbar {font-size: 10px;} .text {color:000000;font-size:11px} a.text:link, a.text:visited {color:ff0000} a.text:hover {color:53f9e1} * html .nametext, * html .whitetext12 { width:298px; } .NOTES { content:"firefox hack to make tables not to have a huge gap"; } td.text {text-align:left;} .r{} body { background-color: 000000; } table table table { border-width: 1; border-style: solid; border-color: 000000; background-color: ffffff; filter: alpha(opacity=90); -moz-opacity: 0.90; opacity:0.90; -khtml-opacity:0.90; } table table table table {filter:none !important; opacity:1 !important; } .r{} .contactTable { width: 300px !important; height: 150px !important; padding: 0px !important; background-image:url(http://h1.ripway.com/palefountain/contact.jpg); background-attachment: scroll; background-repeat: no-repeat; } .contactTable table, table.contactTable td { padding: 0px !important; border: 0px; background-image: none; } .contactTable a img { visibility: hidden; padding: 2px !important; } .contactTable .text { font-size: 17px !important; } .contactTable .text, .contactTable a, .contactTable img { filter: none !important; } .contactTable .whitetext12 { display: none; } .r{} .r{} body, table table tr td, table table div, li, p, .redtext, .blacktext10, .text, a.text:link, a.text:visited, a.searchlinksmall, a.searchlinkSmall:hover, a.searchlinksmall:link, a.searchlinksmall:visited, .lightbluetext8, a, a:link, a:visited, a.redlink:link, div, font, a.navbar:link, a.navbar:visited { color: 000000; font-size:11; } a.searchlinksmall, a.searchlinksmall:link, a.searchlinksmall:visited { font-weight:normal;} .r{} .nametext, .whitetext12, .orangetext15, .btext, .redbtext, .blacktext12, table.userProfileURL strong { margin: 0px 0px 0px 0px; color: 000000; font-size:10; font-family: Trebuchet MS, sans-serif; font-weight:bold; } .whitetext12 { margin-top:0; } .r{} span.blacktext12 { padding-bottom:; visibility: visible !important; background-repeat: no-repeat; font-size: px; text-transform: uppercase; letter-spacing: px; width: ; height: ; display: block !important; background-image:url(); } .blacktext12 { text-align:center; margin-top:0px;} .nametext, .whitetext12, .orangetext15, .btext, table.userProfileURL strong { padding-top: 2; padding-right:2; padding-bottom:2; padding-left:4; border-style: none; } .nametext { font-size:10; font-family: Trebuchet MS, sans-serif; background-color:transparent; } .r{} .lightbluetext8 { color: 000000; font-size:10; font-weight:normal; } .r{} .r{} a, a:link, a:visited, a.redlink:link, a.redlink:visited, a.navbar:link, a.navbar:visited, a.text:link, a.text:visited, a.text:hover { color: ff0000; font-size:10; font-weight:normal; text-decoration:none; } a.navbar:link, a.navbar:visited, a.text:link, a.text:visited, a.text:hover { } a:hover, a.redlink:hover, a.navbar:hover, a.text:hover { color: 53f9e1; font-size:10; font-weight:normal; text-decoration:underline; } a.navbar:hover, a.text:hover { } .NOTES { content:'make font smaller for friends comments box';} a.navbar:link, a.navbar:visited, a.navbar:hover, a.text:link, a.text:visited, a.text:hover { font-weight:normal; font-size:9px;} *html table table table { height: .01%; } table, td { padding: 0px; } table table table { height: .01%; width: 100%; padding: 0px; } table table table table { padding: 0px; } table table table table table { padding: 0px;} table table table table table table { padding: 0px;} td.text td.text table table table td {padding:0px 6px 0px 6px !important; } * html .contactTable, *html .userProfileURL {width: 300px !important;} </style> If someone can just point me in the right direction, or better yet implement the/a code that will keep the banner where i want it plus having the image maps, i would be over the moon as this little thing is really getting on my nerves !haah! Oh yes, also... Instead of imape mapping I tried to play a sneaky little trick by laying a transparent clickable div layer over the buttons in the image but they change position in every browser and different screen resolutions so no good! Thank you in advance for any advice... So I've actually only started using HTML about four days ago. As soon as I made a website, I decided it was time. I know everyone dislikes iFrames, etc., but it's right for my site. ;D Anywho... My first problem is that I can't seem to use image maps correctly. I've done everything; I even downloaded cutemap and some other image mapping programs. I'm not quite sure what I'm doing wrong? Can anyone here correct me on my coding or my mistake? I'm a bit confused. http://amberz.webs.com/ (Just a test site.) Even though I used image map and all, you can't click on any of the links. This is the exact HTML I've been working for this index page. HTML Code: <div style="text-align:center;"><iframe src="http://i763.photobucket.com/albums/xx280/Summer-breeze/Graphics/SummerBreezeLayout.png" width="635" height="602" scrolling="auto" frameborder="0"> <body><map id="imgmap2009712214216" name="imgmap2009712214216"><area shape="rect" alt="" title="" coords="438,297,613,340" href="http://summer-breeze.webs.com/info.htm" target="_self" /><area shape="rect" alt="" title="" coords="531,343,614,366" href="http://summer-breeze.webs.com/crew.htm" target="" /><area shape="rect" alt="" title="" coords="523,370,616,403" href="http://summer-breeze.webs.com/adoptions.htm" target="_self" /><area shape="rect" alt="" title="" coords="482,405,617,436" href="http://summer-breeze.webs.com/graphics.htm" target="_self" /><area shape="rect" alt="" title="" coords="426,438,621,473" href="http://summer-breeze.webs.com/photography.htm" target="_self" /></map></body> <iframe name="I1" id="I1" src="http://www.example.com" marginwidth="1" marginheight="1" height="343" border="0" frameborder="0" style="width: 355px" scrolling="auto"> </iframe> <!--This bit is only viewed by browsers that don't support inline frames --> Your browser doesn't support inline frames. </iframe></div> Another question I have is: How can I make it so the image is fixed? I'm probably going to have a lot of content on my site, and it's a non-repetitive image, which will just look silly. http://i763.photobucket.com/albums/x...Background.png This is the image I'll be using for the sub-pages, and if I can figure out how to image map correctly, it'll include a link back home. Thank you to anyone who can help. Sorry for sounding like such a frames/HTML n00b ahaha. My goal is to create a website to display a yearbook. First I wanted to display the overall page, with imagemapping to enlarge any images on the page, whether it be a group photo, an indivdual photo...etc. Some pages could have 1 image, others could have 40 images, and not each page has the images in the same spot, so each page would require it's own image mapping. My question is how do I work around screen resolution? I would prefer to use divs and tables for % imaging, but if I do, I can't use an image map. Or is there a way to make an image map that is also based on %? The whole project will encompass about 70 pages of images. Thanks Wondering if it's possible to make a circular image change to a different image on mouseover for each of the links in the sample photo. I'm thinking this would be easy to do if the image were square and not circular. Sorry if this is in the wrong section. Is this possible and could you point me in the right direction? Does anyone know the form for hotmapping an image of the US map with the states PA, NJ, and DE? the map is called "usmap.jpeg" and the coords for a state a is PA: 453,133,458,130,461,132,504,123,510,130,508,135,513,145,505,153,461,160,455,134 If you could post the code lines for the map appearing with the PA hotspot, then I can figure out the rest of the states. Thanks you very much! (code from <body> to the end of the hotspot.) And you don't need to see the image to plant the spots. I just need the code for the image and the PA hotspot. I was wonder what browser or editing program that I can use to see my webpage that would show the map coords as I move my mouse around the webpage please? Thank You in Advance. On my site I am trying to have 2 separate images load randomly, that part I have figured out, however, each image is actually a 2 sided banner with a link on each side, as of right now I am using the code below link each image to a single page, however, I need to map 2 different links on the image and I'm unsure how I should edit the code to do that: function showImage(){ if(whichImage==0){ document.write('<a href ="link.html"><img src="'+theImages[whichImage]+'" border=0 width=645 height=125></a>'); } else if(whichImage==1){ document.write('<a href ="link.html"><img src="'+theImages[whichImage]+'" border=0 width=645 height=125></a>'); } else if(whichImage==2){ document.write('<a href ="link.html"><img src="'+theImages[whichImage]+'" border=0 width=645 height=125></a>'); } else if(whichImage==3){ document.write('<a href ="link.html"><img src="'+theImages[whichImage]+'" border=0 width=645 height=125></a>'); } else if(whichImage==4){ document.write('<a href ="link.html"><img src="'+theImages[whichImage]+'" border=0 width=645 height=125></a>'); } } </script> Hi all -- I'm having an interesting problem. I'm designing a web page that has a navigation banner (home - programs - schedule of events - contact us - downloads) that is made up of a .png for each page (i.e. home.png, programs.png, etc). My page is 1000px wide and all of the navigation banner's images add up to 1000px wide. I'm using JavaScript to create an onMouseOver and onMouseOut effect on each of the images. The problem that I'm having occurs when I tried to add a link (either by <A HREF= or using an image map). Whenever I add a link to the image, a small (3px) area of white space shows up to the right of the image. This shifts all of my other images 3px to the right (and 3 more for each link I add to subsequent images) thus making the total width of the navigation banner over 1000px and the last image gets shoved to a new line. I can find no way to get rid of this white space other than to remove the link from the image. There is no property on the page that adds any sort of padding, margins, or borders to images or links, so I can see no property that has to be changed. Help! How do I get rid of this white space but still keep the link on the image?? [I posted this question on the Adobe forum to no avail, below is a screencap I took of the issue I'm having] Thanks in advance! //kl PS - I am using both IE8 and Chrome to view this webpage. I've set all the margins/padding/borders to 0px. Here is my CSS and the part of the code that pertains to the navigation banner. CSS: Code: <style type="text/css"> <!-- body { font: 100% Verdana, Arial, Helvetica, sans-serif; background: #666666; margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */ padding: 0; text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */ color: #000000; background-image: url(images/blue.bg.png); background-repeat: repeat; background-color: #009; } .oneColFixCtr #container { width: 1000px; /* using 20px less than a full 800px width allows for browser chrome and avoids a horizontal scroll bar */ background: #FFFFFF; margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */ border: 0px solid #000000; text-align: left; /* this overrides the text-align: center on the body element. */ } .oneColFixCtr #mainContent { padding: 0 20px; /* remember that padding is the space inside the div box and margin is the space outside the div box */ } body, td, th { color: #333; } #main_banner2 { margin: 0px; padding: 0px; height: auto; width: 1000px; } --> </style> </head> Nav Banner: NOTE:: below HAS to be all one paragraph because if i insert a carriage return in between images, it also adds the white space... Code: <body class="oneColFixCtr"> <!-- MAIN NAVIGATION BANNER --> <!--HOME--><img src="images/nav/home.png" alt="home" name="home" width="82" height="30" border="0" onMouseOver="document.images.home.src='images/nav/home_over.png'" onMouseOut ="document.images.home.src='images/nav/home.png'"/><!--PROGRAMS--><img src="images/nav/programs.png" width="111" height="30" border="0" name="programs" onMouseOver="document.images.programs.src='images/nav/programs_over.png'" onMouseOut ="document.images.programs.src='images/nav/programs.png'"/><!--SCHEDULE OF EVENTS--><img src="images/nav/scheduleofevents.png" width="189" height="30" border="0" name="scheduleofevents" onMouseOver="document.images.scheduleofevents.src='images/nav/scheduleofevents_ over.png'" onMouseOut ="document.images.scheduleofevents.src='images/nav/scheduleofevents.png'"/><!-- CONTACT US--><img src="images/nav/contactus.png" width="119" height="30" border="0" name="contactus" onMouseOver="document.images.contactus.src='images/nav/contactus_over.png'" onMouseOut ="document.images.contactus.src='images/nav/contactus.png'"/><!--DOWNLOADS--><i mg src="images/nav/downloads.png" width="267" height="30" border="0" name="downloads" onMouseOver="document.images.downloads.src='images/nav/downloads_over.png'" onMouseOut ="document.images.downloads.src='images/nav/downloads.png'"/><!--FACEBOOK--><im g src="images/nav/facebook.png" width="90" height="30" border="0" name="facebook" onMouseOver="document.images.facebook.src='images/nav/facebook_over.png'" onMouseOut ="document.images.facebook.src='images/nav/facebook.png'"/><!--TWITTER--><img src="images/nav/twitter.png" width="67" height="30" border="0" name="twitter" onMouseOver="document.images.twitter.src='images/nav/twitter_over.png'" onMouseOut ="document.images.twitter.src='images/nav/twitter.png'"/><!--BLOGGER--><img src="images/nav/blogger.png" width="75" height="30" border="0" name="blogger" onMouseOver="document.images.blogger.src='images/nav/blogger_over.png'" onMouseOut ="document.images.blogger.src='images/nav/blogger.png'"/><img src="images/home_banner.png" alt="home_border" width="1000" height="7" /><br /> So in January 2006 I posted a question about "making two buttons in one" 3 years and 5 months later i am happy to announce that I have found a solution. Ok, so no I have not spent the last three years looking, but the need for one came around again yesterday so I revisited the project. All I needed was "simple" image toggle. Image 'A' click it once it changes to image 'B' click it again it changes back to image 'A' All the "image toggle" codes I could find were extremely complex. I thought I had finally found one, it wasn't perfect, but it was the smallest and most basic thing I could find. HTML Code: <html> <head> <style type="text/css"> .on {background-image:url(playlist_btn.png); background-repeat:no-repeat;} .off {background-image:url(playlist_btn_x.png); background-repeat:no-repeat;} </style> <script language="javascript"> function togglestyle(el){if(el.className == "on") {el.className="off";} else {el.className="on";}} </script> </head> <body> <div id="onoff" class="playlist_btn"><img src="blank.gif" width="50 height="50" onclick="togglestyle(onoff)"></div> </body> </html> I tested it, it worked, so I considered problem solved. I placed it in my page and nothing. Turns out it wont work with a doc type - so it's useless. Other problems, I'm not big on using "blank gif's" unless I have to, if you want multiple image toggles you need a new JS function for each one, and two lines of css as well. And, though I rarely use image rollovers anymore, it would certainly not be possible in this method. So it was back to the drawing board. Well, I had actually already found the solution a few minuets prior to finding out that the above code is so good. I had coded a button that on rollover shows a tooltip, when you click the button, the text in the tool tip, changes, chick again and it reverts. All done with a simple showHide javascript function, that i am finfing out has many uses. here is the awesome code: Code: function showHide(elementid){ if (document.getElementById(elementid).style.display == 'none'){ document.getElementById(elementid).style.display = ''; } else { document.getElementById(elementid).style.display = 'none'; } } function hideShow(elementid){ if (document.getElementById(elementid).style.display == ''){ document.getElementById(elementid).style.display = 'none'; } else { document.getElementById(elementid).style.display = ''; } } I wont take credit for the showHide code, but I will take credit for the hideShow portion, obviously a monkey could have coded the revers, but iot does make it that much more universal. As the original code was designed to show something that was hidden, add the revers to hide something that is showing and it's perfect. Now I will take a moment to say, though I have yet to find a problem with the code, it seems to work in most browsers, firefox, ie, safari, and validates for WC3 - In sure it has it's flaws. Until now, to show and hide divs I had used the MM_showHideLayers JavaScript function, which by default used the visibility style. It is of course a good script, and has many uses, it's not very big, but it is somewhat complex. The other thing to think about is that invisible objects still take up space. That's what is cool about the display:none: style, is that is not only invisible but it doesn't take up space. So here is how I used the above to JavaScript to make a simple onclick image toggle: HTML Code: <img id="on" src="on.png" width="50" height="50" onClick="javascript:hideShow('on'); javascript:showHide('off')" alt="on"> <img id="off" src="off.png" width="50" height="50" onClick="javascript:hideShow('off'); javascript:showHide('plus')" style="display:none;" alt="off"> Cool huh? Now this example does not have a rollover either, but since it uses to individual images and is not replacing one image wioth another you could easily apply a rollover to both images. But, hold on, look at the above code, isn't that essentially a rollover? Change the first onClick to onMouseOver and the second to onMouseOut and look at that a 'brand new' method for mouseovers. So lets take a look at this for a second, and compare MM_swapImage to this new hideShow method. As far as CSS rollovers I definitely prefer them to the MM_swapImage method, as they use a minimal amount of code. However they actually take a lot of math, construction the buttons is somewhat tedious, because css buttons use 1 image and change it's position, to work well you have to use a "blank.gif" and the the css can really add up if you have a lot of buttons: Also, you can't go directly to a button in the document, you have to fish through the css to make any adjustments. But they are fast, they don't need to be preloaded and... they are pretty cool. But anyway, swapImage and hideShow... The left is the MM_swapImage method. Now when you use the swapImage js you also have to use MM_swapImgRestore, MM_findObj, MM_preloadImages. You don't have to use the preload script but it does make thing work faster... supposedly, but that requires a onload script in the body tag, and if you have a lot of rollovers your body tag can get really long really quick. So what are the advantages, well we know for sure it works, and you only need on image in the document, however actualy having the image you are "swapping" too actually in the document can add functionality. So as you can see, on the right, the showHide method is, in total code, much smaller. True you do need to use two images, so the total code in the body is longer but, it's more than evened out bu the minimal JavaScript, and I think it's worth it. You don't need to use a preloader, you have full control over both images, the up and over state, and unlike the swapImage method, though it's rare you would need to, your up and over images can actually be different sizes, which is kind of cool. So here's the basic code for a rollover: HTML Code: <img id="up" src="up.png" width="50" height="50" onMouseOver="javascript:hideShow('up'); javascript:showHide('over')" alt="up"> <a href="http://google.com"><img id="over" src="over.png" width="50" height="50" onMouseOut="javascript:hideShow('over'); javascript:showHide('up')" style="display:none;" alt="over" border="0"></a> To add a link the button you just apply it to the "over state" image. And unlike swapImage, though it is overkill, you can also add a "downstate" image quite easily. So, back to the on/off button here is how you would code it using showHide with rollovers. HTML Code: <img id="on" src="on.png" width="50" height="50" onMouseOver="javascript:hideShow('on'); javascript:showHide('onover')" alt="on"> <img id="onover" src="on_over.png" width="50" height="50" onMouseOut="javascript:hideShow('onover'); javascript:showHide('on')" onClick="javascript:hideShow('onover'); javascript:showHide('offover')" style="display:none;" alt="onover"> <img id="off" src="off.png" width="50" height="50" onMouseOver="javascript:hideShow('off'); javascript:showHide('offover')" style="display:none;" alt="off"> <img id="offover" src="off_over.png" width="50" height="50" style="display:none;" onMouseout="javascript:hideShow('offover'); javascript:showHide('off')" onClick="javascript:hideShow('onover'); javascript:showHide('off')"alt="offover"> So here is what is going on: you have the upstate on.png image, when you mouse over it on.png is hidden and on_over.png is displayed. When you click on_over.png it is hidden and off_over.png is display, mouse off it and off.png is displayed. Make scene? Now be aware, when you click, you are also in a scene "mousing off" so some flickering can occur. Firefox handles everything pretty well, IE and Safari not so much. When you click the on_over.png the click tells it to hide on_over.png and show the off_over.png, at the same time the mouseoff tells it to hide on_over.png and show the on.png. So fortunately the toggle with rollovers isn't perfect, but perhaps some more tweaking of the code or maybe, in this case swapImage would work better to do the rollovers... But all in all I'd say its a solid concept. If you feel compiled to do so, reply with any comments, concerns or flaws you see. Hey guys. I need a little help with my HTML image rotator. Everything works fine, except the images don't show up on the right slide. All 4 images show up on the first slide. I can't figure out what's wrong. Any help will be greatly appreciated. Code: <!DOCTYPE html> <html> <head> <title>...</title> <style> #sliderwrap { height: 403px; } #sliderleft { width: 10px; height: 100%; float: left; background: #efefef; border: 1px solid #ccc; } #sliderleft div { height: 100px; border-bottom: 1px solid black; } #slidercontent { position: relative; width: 650px; height: 100%; float: left; border: 1px solid black; overflow: hidden; } #sliderimages { position: absolute; -webkit-transition: all .5s ease-in-out; -moz-transition: all .5s ease-in-out; -ms-transition: all .5s ease-in-out; -o-transition: all .5s ease-in-out; transition: all .5s ease-in-out; } #sliderimages img { display: block; } .s0 #slide0, .s1 #slide1, .s2 #slide2, .s3 #slide3 { background: #ccc; } .s0 #sliderimages {top: 0 } .s1 #sliderimages {top: -500px} .s2 #sliderimages {top: -1000px} .s3 #sliderimages {top: -1500px} </style> <script> var slide = 0; var interval_id = 0; function stop_timer() { clearInterval(interval_id); if (this.getAttribute("data-slide")) { slide = parseInt(this.getAttribute("data-slide")); document.getElementById("sliderwrap").className = "s" + slide; } } function start_timer() { clearInterval(interval_id); interval_id = setInterval( function() { slide = (slide + 1) % 4; document.getElementById("sliderwrap").className = "s" + slide; }, 3000 ); } window.onload = function() { start_timer(); var el = document.getElementById("slidercontent"); var divs = document.getElementById("sliderleft").getElementsByTagName("div"); for (var i = 0; i < divs.length; i++) { divs[i].onmouseover = stop_timer; divs[i].onmouseout = start_timer; } el.onmouseover = stop_timer; el.onmouseout = start_timer; } </script> </head> <body> <div id="sliderwrap" class="s0"> <div id="sliderleft"> <div id="slide0" data-slide="0"></div> <div id="slide1" data-slide="1"></div> <div id="slide2" data-slide="2"></div> <div id="slide3" data-slide="3"></div> </div> <div id="slidercontent"> <div id="sliderimages"> <img src="http://i.imgur.com/8iWz6.jpg"> <img src="http://i.imgur.com/1d2U6.jpg"> <img src="http://i.imgur.com/8iWz6.jpg"> <img src="http://i.imgur.com/1d2U6.jpg"> </div> </div> <div style="clear: both;"></div> </div> </body> </html> the title makes it sounds really confusing. Ok im making my first website, and i need help with a code, (as you can see on www.dalekblaster.co.uk) i have got a section at the top where the images change from one to another. The code is - HTML Code: // Set slideShowSpeed (milliseconds) var slideShowSpeed = 5000; // Duration of crossfade (seconds) var crossFadeDuration = 5; // Specify the image files var Pic = new Array(); // to add more images, just continue // the pattern, adding to the array below Pic[0] = 'http://www.dalekblaster.co.uk/images/banner/dalekblasternexttime.jpg' Pic[1] = 'http://www.dalekblaster.co.uk/images/banner/dalekblaster2.jpg' Pic[2] = 'http://www.dalekblaster.co.uk/images/banner/dalekblastersjanexttime.jpg' Pic[3] = 'http://www.dalekblaster.co.uk/images/banner/dalekblaster.jpg' // do not edit anything below this line var t; var j = 0; var p = Pic.length; var preLoad = new Array(); for (i = 0; i < p; i++) { preLoad[i] = new Image(); preLoad[i].src = Pic[i]; } function runSlideShow() { if (document.all) { document.images.SlideShow.style.filter="blendTrans(duration=2)"; document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"; document.images.SlideShow.filters.blendTrans.Apply(); } document.images.SlideShow.src = preLoad[j].src; if (document.all) { document.images.SlideShow.filters.blendTrans.Play(); } j = j + 1; if (j > (p - 1)) j = 0; t = setTimeout('runSlideShow()', slideShowSpeed); Now i need help because, i want to link each picture on the slideshow to a differnet page or external site, but im not sure how. (but so they can go to different pages not the same one) can anyone help me? I'm not sure if this is an IE issue, css, html... I have all icons and images showing a broken image" red X OVER the actual image? I've never seen this on any other sites or even on any other sites i've done. They are all .png images but I use .png files successfully all the time? Anyone encounter this? Here's the HTML surrounding the image file: HTML Code: <div class="header logo2"> <!-- Logo begins here --> <a href="index.php" title=""><img src="images/logo.png" alt="" /></a> </div> <!-- END Logo --> Here's the CSS surrounding the image with no other images or backgrounds being called??? HTML Code: .header { height: 41px; } .logo2 { text-align: right; } See Image Attached... |