faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

7 of 15 people (47%) answered Yes
Recently 3 of 10 people (30%) answered Yes

Entry

How can I change the image and show collapsed text when I click the image?

Apr 6th, 2008 18:38
ha mo, Colin Fraser, Weijun Zhang,


Try
function swapLayer(layer1name, layer2name) {
	if (navigator.appName=="Netscape") {
            layer1name.visibility ="hide";
            layer2name.visibility="visible";     
        }
	else {
          if (navigator.appName=="Microsoft Internet Explorer"){
            layer1name.visibility = "hidden"
            layer2name.visibility="visible";  }
          }
    }
<div id="imagelayer" style="{visibility:visible;}">  
<img src="myImage.gif onClick=swapLayer("imageLayer, textLayer")>
>
</div>
<div id="textLayer" style="{visibility:hidden;}>
<a href="javascript:void()" onClick=swapLayer("textLayer, imageLayer")
Collapsible text</a>
</div>
Of course, the major problem comes from the fact that there are more
than two browsers out there, so what happens if someone is using a
browsert hat is nioether N or IE?
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com