JAVA help

biferi

Daemon Poster
Messages
690
I am trying to do Rollover images for my web page and need some hlp.

I know you need 2. images the same but a little diferant. And on image is say called ballON.gif and the other image is called ballOOF.gif

And you use the basic code to place the one image on the page and you would use the basic code to make that image a Link to the page you want to link to.

I get this I do that all thwe time.

And the secound image you do the same thing to.

Now it is the Java code that will make everything work togather.

Am I right so far??????

So this is how I have everything setup all my HTML files and Photos and everything for my web site is in the same Folder.

So what would the whole code be for if I wanted to make Rollover image

ballON.gif and ballOFF.gif

And I want it to link to the index.HTML page wen the mouse is over it?????????
 
Sorry, but I'm struggling to see what on earth this has to do with Java?!
 
Sounds like you're confusing Java with Javascript. The two are VERY different - Java has absolutely nothing to do with this. Google around if you're still confused and you'll very quickly find out what the differences are!

Either way, you don't need Javascript either these days - you can do it through CSS (which is a much better alternative.)

Have a look here for an example:
http://www.tutorio.com/tutorial/pure-css-image-rollovers
 
Thanks but do you think you could tell me or show me an easyer link to do this?

I did get a litle mor confused?
 
Sorry - but this time I'm going to be firm and say no, I'm not going to go and search Google and find an article that tells you exactly what to do and how to do it. I can't remember a single time here when you've gone away and done something because of an answer here, all the times I've remembered you've just asked for an easier way to do it that involves no effort on your part whatsoever.

If you've TRIED things and failed, or only got half way there then fair enough. I'm all up for helping people who put the effort in but genuinely struggle for whatever reason. But you haven't shown any evidence that you've tried to do the above - and since you've been asking basic web questions on here for a while now, I don't think it's too much to expect you to have gone away and done at least a bit of research.

The last resource I'm going to point you at for now is this one. Head over to there and follow through the tutorials on HTML, XHTML (which you should really be using over HTML these days) then CSS. Once you've done that, move onto Javascript, PHP and SQL as well if you like. Study them carefully, work through the examples and code some basic things yourself, without just copying and pasting from the site. Try different things out, understand how they work together and make sure you're fully conversant with one stage before moving onto the next. It's not something that will come instantly - but that's something you need to accept. If everything in the computing world was simple, straightforward and came to people straight away then I wouldn't still be learning things after a decade or so.

You've got to the point now where you need to stop searching for an "easier" way to do everything and start accepting the standard way of doing things. If you follow the above tutorials through and understand them fully, implementing the various examples people have pointed you towards (including the one in this thread) will be an absolute piece of cake - and that's assuming you need them at all!

Specific questions on various points or concepts you're struggling with are completely understandable. Post something querying why your javascript is preventing your XHTML from validating for example and I'll be happy to answer. Just asking people to do things for you though won't get you anywhere.
 
Berry is correct, this requires JavaScript rather than Java. I believe what's below is exactly what you want.

Place within the <head></head> tags:
Code:
<script type="text/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 MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
Now look for the tag <body> and change it to:
Code:
<body onload="MM_preloadImages('CHANGE_TO_IMAGE2_NAME.gif')">
Where CHANGE_TO_IMAGE2_NAME is what you want to appear on mouse over.

Finally the image:
Code:
<img src="CHANGE_TO_IMAGE1_NAME.gif" width="250" height="200" id="Image1" onmouseover="MM_swapImage('Image1','','CHANGE_TO_IMAGE2_NAME.gif',1)" onmouseout="MM_swapImgRestore()" />
Where CHANGE_TO_IMAGE1_NAME is the name of the image to show originally and CHANGE_TO_IMAGE2_NAME is what will replace image1 on mouse over.

Hope it helps,
hockeygoalie5.
 
Back
Top Bottom