Jump to content
  • Advertisement
Sign in to follow this  
Ekim_Gram

[web] JavaScript Problems

This topic is 5406 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm having some problems with my rollovers with javascript on my band's website. The problem is in explorer only so its crucial that I fix it. The layout of my site uses frames and I'm having trouble with the top frame ( indexbar.html) where you click the picture and the bottom frame changes. The rollovers work for 2 out of the 7 pictures, why the two don't I have no clue. So if somebody would be as so nice to go to indexbar.html and check out the source for me, that'd be much appreciated. At the risk of losing helpers, I'll post the code here as well: [NOTE: I DID NOT MAKE THE DESIGN. I'M JUST DOING THE SCRIPTING FOR THE SITE SO YOU CAN'T YELL AT ME FOR USING FRONTPAGE BECAUSE I DIDN'T]
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-[[1252]]">
<meta name="GENERATOR" content="Microsoft FrontPage [[4]].[[0]]">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Three Piece Suit</title>
<base target="_self">
	<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
	<!-- Hide script from old browsers

	if (document.images)
	{
		media = new Image
		home = new Image
		merch = new Image
		shows = new Image
		bio = new Image
		contact = new Image
		links = new Image
		tps = new Image

		media.src = "media.gif"
		home.src = "home.gif"
		merch.src = "merch.gif"
		shows.src = "shows.gif"
		bio.src = "bio.gif"
		contact.src = "contact.gif"
		links.src = "links.gif"
		tps.src = "tps.gif"
	}
	else
	{
		media.src = ""
		home.src = ""
		merch.src = ""
		shows.src = ""
		bio.src = ""
		contact.src = ""
		links.src = ""
		tps.src = ""
		document.textField = ""
	}

	// End hiding script from old browsers -->
	</SCRIPT>
</head>

<body background="ska.gif">

<p>
<span style="position: absolute; left: [[613]]; top: [[77]]">
 <img border="[[0]]" src="tps.gif" width="[[345]]" height="[[71]]" name="textField" alt="tells the links">
</span>

<span style="position: absolute; left: [[82]];  top: [[3]]">
 <a href="Media.html" target="_parent" onMouseover="document.textField.src = media.src"
 									 onMouseout="document.textField.src = tps.src">
  <img border="[[0]]" src="alex.jpg" width="[[62]]" height="[[232]]">
 </a>
</span>

<span style="position: absolute; left: [[159]]; top: [[33]]">
 <a href="Bio.html" target="_parent" onMouseover="document.textField.src = bio.src"
 									 onMouseout="document.textField.src = tps.src">
  <img border="[[0]]" src="eug.jpg" width="[[61]]" height="[[217]]">
 </a>
</span>

<span style="position: absolute; left: [[235]]; top: [[13]]">
 <a href="Merch.html" target="_parent" onMouseover="document.textField.src = merch.src"
 									   onMouseout="document.textField.src = tps.src">
  <img border="[[0]]" src="rob.jpg" width="[[56]]" height="[[212]]">
 </a>
</span>

<span style="position: absolute; left: [[311]]; top: [[43]]">
 <a href="ThreePieceSuit.html" target="_parent" onMouseover="document.textField.src = home.src"
 											    onMouseout="document.textField.src = tps.src">
  <img border="[[0]]" src="Erik.jpg" width="[[56]]" height="[[202]]">
 </a>
</span>

<span style="position: absolute; left: [[382]]; top: [[20]]">
 <a href="Shows.html" target="_parent" onMouseover="document.textField.src = shows.src"
 									   onMouseout="document.textField.src = tps.src">
  <img border="[[0]]" src="Brad.jpg" width="[[62]]" height="[[188]]">
 </a>
</span>

<span style="position: absolute; left: [[459]]; top: [[33]]">
 <a href="Links.html" target="_parent" onMouseover="document.textField.src = links.src"
 									   onMouseout="document.textField.src = tps.src">
  <img border="[[0]]" src="willy.jpg" width="[[58]]" height="[[217]]">
 </a>
</span>

<span style="position: absolute; left: [[535]]; top: [[29]]">
 <a href="Contact.html" target="_parent" onMouseover="document.textField.src = contact.src"
 									     onMouseout="document.textField.src = tps.src">
  <img border="[[0]]" src="mike.jpg" width="[[54]]" height="[[188]]">
 </a>
</span>
</p>

</body>

</html>









EDIT: I have no clue why the source tag puts []'s around number declarations so just to make it clear, that wasn't me.

Share this post


Link to post
Share on other sites
Advertisement
Hello,

Why don't you try and make a javascript function like so:


function ChangeSource(ImgSource)
{
document.textField.src = ImgSource;
}





Then on the onmouseover and onmouseout events call that function instead.

<a href="somepage" onmouseover="ChangeSource(To.src)" onmouseout="ChangeSource(Back.src)">

don't know if it will work but it's worth a shot.

Richard

EDIT:

The links one doesn't seem to work for any of the browsers that I have (IE6, Netscape7.2, Mozilla Firefox). Maybe you should try renaming the image variables to something other then media and links.

[Edited by - BigR on September 27, 2004 1:47:40 AM]

Share this post


Link to post
Share on other sites
It's not the image variable, it's the image itself. media.gif and links.gif just won't load. You could go to www.threepiecesuit.net/media.gif and it'll load but it won't work by itself in the javascript.

Share this post


Link to post
Share on other sites
Hello again,

I actually took your source and changed the javascript variable names of media and links to Mymedia and Mylink respectively and it seems to work fine. I've uploaded the edited version to my server and you can find it here.

Have fun learning javascript, I know I did ;-)

Richard

Share this post


Link to post
Share on other sites
Thank you so much buddy! I guess I should have tired changing the names, you never know what's going to work in any programming language. Me, and my band give you a great thanks alot and you have our utmost appreciation.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!