...

View Full Version : Image changer



PeterJS
06-08-2003, 01:13 PM
I have a board where you can change the logo in the header, but want to change it for each forum, so it's a different image. I have this script.....


<script language="JavaScript">
for(i=0 ; i<document.images.length ; i++){
if(document.images[i].src=="URL HERE"){
document.images[i].src="URL HERE"
}
}
</script>

Is there a way to change the image without the user noticing it change. Because at the moment when you goto into a forum, you see the previous image for a split second before it changes.

Thanks

Peter

STDestiny
06-08-2003, 03:57 PM
It would probably be better if you used a server side script to do it. Just look in hotscripts.com under images for whatever language you need.

-Andrew

brothercake
06-08-2003, 05:08 PM
You could set the initial SRC to a blank image, then change it to the real one; that way, you wouldn't see the previous image.

Graeme Hackston
06-08-2003, 05:15 PM
document.images is depreciated, I guess because getElementsByTagName does the same thing.



css

.myImages {
visibility; hidden;
}

js

var document_images = document.getElementsByTagName('img')
var document_images_length = document_images.length

for(i=0 ; i<document_images_length ; i++){
if(document_images[i].src=="URL HERE"){
document_images[i].src="URL HERE"
document_images[i].style.visibility = 'visible'
}
}

html

<img class="myImage">


I don't understand why you're using a loop. You don't need to if it's only 1 image per page

PeterJS
06-08-2003, 05:31 PM
Problem is, I can't change the HTML on the forum, I can only add to it, with JS, CSS, HTML etc. It's a remotely hosted forum.

Thanks

Peter



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum