PDA

View Full Version : java/html problems


Cherokee Red
03-02-2004, 04:08 PM
Ok i want to add a couple of extra's to my new site.
it's a basic html site that i wrote myself (ie, not using any editing programs besides from windows notepad)

My problem is adding in the script. I want a couple of image roll-overs added, but the script never seems to work.
Any ideas? or am i just pap at editing? :p
here's the code i've been working with -


< !-- STEP ONE: Paste this code into the BODY of your HTML document -->
< body >
< script language="JavaScript" >
//Preload knight Images
knighted=new Image(32,48)
knighted.src="C:/Documents and Settings/Kenny/Desktop/web/pic/home.jpg"
knightred=new Image(32,48)
knightred.src="C:/Documents and Settings/Kenny/Desktop/web/pic/home2.jpg"
< /script >
< !-- create mouse-over effect - ->
< a href="http://www.bravenet.com" onMouseOver="document.knight.src=knightred.src" onMouseOut="document.knight.src=knighted.src" >< img name="home2" src="C:/Documents and Settings/Kenny/Desktop/web/pic/home2.jpg" border="0" ></ a >
< body >


this is after i edited it a bit, i can get the orginal script if required.
I've tried a few others aswell. any rcommendations?

also, I have put in a status bar rollover (when you roll over a link and a message is desplayed in the status bar).
Can i add in the image roll-over on top of this??
Any help would be greatfully accepted.

click my sig to see the site i am talking about. the links menu on the left is where i want the roll-overs to be.

edit - fixed my sig to the right site now.

Mystical Parrot
03-02-2004, 04:26 PM
err you cant host pictures on your own computer you know?

Cherokee Red
03-02-2004, 04:29 PM
i know, but i was editing off line.

i'll change the code to a hosted pic if it helps?

Mystical Parrot
03-02-2004, 04:32 PM
i dunno ive never tried to learn java script sorry

Ninja Duck
03-02-2004, 04:38 PM
Originally posted by Mystical Parrot
err you cant host pictures on your own computer you know?

It ought to work as long as the files are where the coding says. i.e. it would only work on Cherokee's computer.

I'm only an amatuer, but I like to pretend that I'm helpful. And I think I might see the problem. The image you want to change is named "home2" when it should be named "knight". So just change the img tag to

< img name="knight" src=...>

And I suppose it should work. Either that on change the mouseover and mouseout to "document.home2.src". I think you get it by now.

wyrd_fish
03-02-2004, 05:07 PM
stand aside mortals...


Step One:
get an new host
try www.port5.com

Step Two:
Don't use status bar messages...
yep, you heard right, get rid of 'em.
very few people even read them and most find them annoying.

Step Three:
use images like this:

<img src="image.gif" onMouseOver="src='image_over.gif'" onMouseOut="src='image.gif'">




that should work, the exrta bit was a preloader, but i don't understand them well in JS...

ash
03-02-2004, 05:09 PM
Originally posted by Ninja Duck
The image you want to change is named "home2" when it should be named "knight". So just change the img tag to

< img name="knight" src=...>


the man is correct

Cherokee Red
03-02-2004, 05:14 PM
Ah, thankyou.
I'll double check it when i get home.

I tried mucking about with them too, but i must have forgotten to change the names from the original.

wryd_fish, i'll try your suggestions too. cheers. post back if/when i get it sorted
:)

HiTmAN
03-02-2004, 09:16 PM
if you want it, here is a handy little rollover function, just put this in the head of your document:

function img_hover(ID, PIC) {
ID.setAttribute('src', PIC)
}

then just use it like this:

<img src="1.gif" onmouseover="javascript:img_hover(this,'2.gif')" onmouseout="javascript:img_hover(this,'1.gif')">

this adheres a bit more to html standards (being the standard-complient freak i am :p)

edit: oh, and if you are changing all the image names for an offline copy and an online copy, here is a tip. instead of putting c:\documents and settings\blah\blah, you can put "./" and it will take that as the current directory.
for example, if it was in C:\folder, putting <img src="./image.gif"> would make the src c:\folder\image.gif
you can also put folders in a relative path like this (e.g "./images/1.gif") also, putting "../" will go down a level in the directory structure. (e.g in c:\folder, ../image.gif will go to c:\image.gif"
so if you have the same folder structure online and offline, you don't have to change all the paths.

Ninja Duck
03-02-2004, 11:24 PM
Originally posted by ash
the man is correct

\o/

When it works, don't be afraid to + me. ;)

Explosivo
13-02-2004, 07:29 PM
is it possible when ur are doing the mouseover command
2 make the image change 2 text

wyrd_fish
13-02-2004, 08:06 PM
i don't think so, and why would ant onw want this any way???

Explosivo
13-02-2004, 08:13 PM
i want it so that my site logo is there and when ppl move the mouse over it it becomes the name of the link hope that helps

l33t k1w1
14-02-2004, 07:36 PM
From an asethics point of view, why do you want that? It'll distract your viewers and if they'll looking for a link, they don't want to go through lots of mouseovers to receive a piece of text telling them if they're right or not.

Explosivo
14-02-2004, 08:49 PM
gd point never though of that

Pigabuff
15-02-2004, 12:02 AM
Er, just so you know, you shouldn't stick the 'preload images' bit in the bosy, my adive is to put it in the head. I don't know if that affects it really, but it make the page load quicker..... I think.

It may not help, but you can always test it ;)

I done that on my site, and it seems to help!



and for editing purposes, it helps to 'tab' your code.

you can take the blank space out latter if you so wish, but I find it helps, because you don't get confused, and say "huh, where was I?"

ash
15-02-2004, 11:29 AM
Originally posted by YYYEEEAAAHHH
is it possible when ur are doing the mouseover command
2 make the image change 2 text

you could put the image you wish to change in a layer and on mouseover change the text of the layer.

dreamweaver can do this for you automatically

the architect
19-02-2004, 12:52 AM
try takingout the body tags, those create a second body section, not to mention it closes neither of them, make the code
< script language="JavaScript" >
//Preload knight Images
knighted=new Image(32,48)
knighted.src="C:/Documents and Settings/Kenny/Desktop/web/pic/home.jpg"
knightred=new Image(32,48)
knightred.src="C:/Documents and Settings/Kenny/Desktop/web/pic/home2.jpg"
< /script >
< !-- create mouse-over effect - ->
< a href="http://www.bravenet.com" onMouseOver="document.knight.src=knightred.src" onMouseOut="document.knight.src=knighted.src" >< img name="home2" src="C:/Documents and Settings/Kenny/Desktop/web/pic/home2.jpg" border="0" ></ a >

and, you need to make sure that you take out the C:/Documents and Settings... bit

a very good question, I hope i gave a good answer

Pigabuff
20-02-2004, 01:18 AM
As I don't see the point in creating my own thread for this, this would seem the perfect place to ask my question!

When doing roll over buttons/images/links you do 'mouseover' and 'mousedown', yes!
Well is there any way of doing this so the mouseover, becomes a sort of visited link sort of thing (I hope you know what I mean!). This is bearing in mind that I'm doing this in frames, so the code would change as the 'menu' page is always visable!

So, what I'm asking is, is there a sort of 'mousevisited' thing in java?