 2008/05/18
|
Last update 1998/09/15
The Labs - Design & Functionality For The NetImproving Web Pages With New Functionalities
Few JavaScript fragments often used to implement user-friendly
web-guidance or intuitive approaches.
- MouseOver Icons
- Updating Multiple Frames
- Resources
| JavaScript1. MouseOver Icons
|
|
<script language=JavaScript>
|
|
<!--//hide script
|
|
|
|
function preload() {
|
|
this.length = preload.arguments.length;
|
|
for (var i = 0; i < this.length; i++) {
|
|
this[i] = new Image();
|
|
this[i].src = preload.arguments[i];
|
|
}
|
|
}
|
|
|
|
function toggle(n,w) {
|
|
if (document.images) {
|
|
for(var i=0; i<document.images.length; i++) {
|
|
var src = document.images[i].src;
|
|
if(src.lastIndexOf("link-"+n)>=0) {
|
|
var off = src.lastIndexOf(".");
|
|
if (off != -1) {
|
|
var newsrc = src.substring(0,off-2) + "."
|
|
+ w + ".jpg";
|
|
document.images[i].src = newsrc;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//end hide script -->
|
|
</script>
|
and then use it with
|
<script language=JavaScript>
|
|
var stuff = new preload(
|
|
"./Images/button-me.0.jpg",
|
|
"./Images/button-me.1.jpg",
|
|
"./Images/button-you.0.jpg",
|
|
"./Images/button-you.1.jpg",
|
|
);
|
|
</script>
|
|
|
|
<a href="..." onMouseOver="toggle(me,1)"
|
|
onMouseOut="toggle(me,0)">
|
|
<img src="Images/button-me.0.jpg"></a>
|
|
...
|
| JavaScript2. Updating Multiple Frames
|
Assuming you have 3 frames named: frame1, frame2, and frame3.
|
<a href="javascript:parent.frame1.location='url1';\
|
|
parent.frame2.location='url2';parent.frame3.location='url3'">
|
|
Update three frames</a>
|
url1, url2, and url3 should be full URLs, if directory are
referenced make sure they end with '/', otherwise you get
an JavaScript error (as it's trying to adjust it and gives
read-only property error).

Last update 1998/09/15 
All Rights Reserved - (C) 1997 - 2008 by The Labs.Com |