Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

Java Script Questions


  • Please log in to reply

#1
zell_ffhut

zell_ffhut

    Member

  • Member
  • PipPip
  • 34 posts
When making a website recently, i created the layout in photoshop, then sliced it up in Image Ready. I then used Image Ready to create rollovers for my buttons. It produced the code, most of which i understand.. But i would love to know what these bits are doing! :tazz:

<script TYPE="text/javascript">
<!--

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		Services_over = newImage("images/Services-over.gif");
		Services_History_over = newImage("images/Services-History_over.gif");
		History_over = newImage("images/History-over.gif");
		Home_History_over = newImage("images/Home-History_over.gif");
		Home_over = newImage("images/Home-over.gif");
		Home_Biography_over = newImage("images/Home-Biography_over.gif");
		Biography_over = newImage("images/Biography-over.gif");
		preloadFlag = true;
	}
}

// -->
</SCRIPT>

If somone could enlighten me to what these functions are actually doing, i would be very happy :) Thanks!
  • 0

Advertisements


#2
lil_cat_luver

lil_cat_luver

    Member

  • Member
  • PipPipPip
  • 296 posts
I think those tell the browser to preload the images used in the rollover.
  • 0

#3
Magosis

Magosis

    Retired Staff

  • Retired Staff
  • 190 posts
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

this is the first function to set the image toggle, and sets the image sources

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

this sets the image toggle values and changes the images on roll over

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		Services_over = newImage("images/Services-over.gif");
		Services_History_over = newImage("images/Services-History_over.gif");
		History_over = newImage("images/History-over.gif");
		Home_History_over = newImage("images/Home-History_over.gif");
		Home_over = newImage("images/Home-over.gif");
		Home_Biography_over = newImage("images/Home-Biography_over.gif");
		Biography_over = newImage("images/Biography-over.gif");
		preloadFlag = true;
	}
}

this preloads the images so there is not a load time when you roll over them.
  • 0

#4
zell_ffhut

zell_ffhut

    Member

  • Topic Starter
  • Member
  • PipPip
  • 34 posts
I see, thanks for your help guys. Its much appritiated :tazz:
  • 0

#5
Magosis

Magosis

    Retired Staff

  • Retired Staff
  • 190 posts
your welcome, glad to help
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP