Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Want to get script working in NN4

Status
Not open for further replies.

JProg

Programmer
Apr 4, 2002
88
JP
Hi Everyone,

I have a script that alternately swaps two images on mouse click, to give the appearance of a button being pressed. The script works fine in IE6, NS7, Firefox, now I want to code it so that it will additionally work in NN4. I have no idea of what commands to use in order to make it work in NN4, any help will be really appreciated. Also if you can see any potential problems with the scripting for IE4 could you please point them out. The script is as follows....
Code:
<html>
<head>
<title> Press Button Emulation Experiment </title>
<style type="text/css">
#nav_button_layer
{
	position:			absolute;
}
</style>
<script src="positioner.js" type="text/javascript"></script>
<script type="text/javascript">
//<!--

var buttonPressed = false;

function swapImage(imageName)
{
	if(document.getElementById)	// IE5+ & NS6+ --> W3C DOM
	{	
		var imageObject = document.getElementById(imageName);
		
		if(!buttonPressed)
		{
			imageObject.setAttribute("src", "button_1.gif");
			buttonPressed = true;
		}
		else
		if(buttonPressed)
		{
			imageObject.setAttribute("src", "button_2.gif");
			buttonPressed = false;
		}
	}
	else
	if(document.all)			// IE 4
	{
		var imageObject = document.all.item(imageName);

		if(!buttonPressed)
		{
			imageObject.src = "button_1.gif";
			buttonPressed = true;
		}
		else
		if(buttonPressed)
		{
			imageObject.src = "button_2.gif";
			buttonPressed = false;
		}
	}		
	else
	if(document.layers)
	{
		var imageObject = document.layers[imageObject];

		// Need to work out code for this section
	}
}

//-->
</script>
</head>
<body>
<div id="nav_button_layer">
	<img id="nav_button" style="cursor:pointer; cursor:hand" src="button_2.gif" onclick="swapImage('nav_button')">
</div>
	<script type="text/javascript">
		setElement('nav_button_layer', 0, 92, 8, 20, 1, "#ffffff");
	</script>	
</body>
</html>
Thanks heaps for your help with this.

Regards

Davo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top