Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Please explain this to me
#1
Hey everyone,

Could someone explain to me what this piece of script does exactly? How does it work?

<!--
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_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_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];}
}
//-->

Thanks loads all ready everyone.

Have a great day.
Reply
#2
As far as I know the MM stands for Macromedia, that is a script generated by Dreamweaver I think for roll-over button effects...
I might be wrong....

EDIT:
I've reasearched a bit and, yes it's a dreamweaver code..

You use it this way...
Code:
<img src="images/square.png" alt="" name="motion3" width="19" height="19" border="0" id="motion3"
onMouseOver="MM_swapImage('motionbox','','images/Test1.jpg','motion3','','images/white.png',1)"
onMouseOut="MM_swapImgRestore()"/>
Found at.. http://forums.digitalpoint.com/showthread.php?t=340315

second edit:
Here I've written a tutorial on how to create button mouse over effects if you're looking to do this...
http://www.supportforums.net/showthread.php?tid=1146
Reply
#3
I thank you very much, this will help me move on again. Smile

What is the find_Obj thing?
Reply
#4
The function looks for a element on which the 2 other functions were called from...
And returns the element/s which were found....

It's called within the swapImage() function and if the findObj function doesn't return NULL it will swap the image..
Reply
#5
could you feed the find_Obj function the necessary information to make it do the swapImage(), I just want to see it work on a site Smile . Sorry to harass you with these probably noob dumbass questions. ;)
Reply
#6
This is how you would call the function...

Code:
<img src="images/square.png" alt="" name="motion3" width="19" height="19" border="0" id="motion3"
onMouseOver="MM_swapImage('motionbox','','images/Test1.jpg','motion3','','images/white.png',1)"
onMouseOut="MM_swapImgRestore()"/>

"images/Test1.jpg" will be swapped with "images/white.png", and "motion3" stands for the element witht he same name... In the above code it's the img tag...

I don't know much about it, since I don't use Dreamweaver.... sorry!
Reply
#7
(01-15-2010, 08:20 AM)Master of The Universe Wrote: As far as I know the MM stands for Macromedia, that is a script generated by Dreamweaver I think for roll-over button effects...
I might be wrong....

EDIT:
I've reasearched a bit and, yes it's a dreamweaver code..

You use it this way...
Code:
<img src="images/square.png" alt="" name="motion3" width="19" height="19" border="0" id="motion3"
onMouseOver="MM_swapImage('motionbox','','images/Test1.jpg','motion3','','images/white.png',1)"
onMouseOut="MM_swapImgRestore()"/>
Found at.. http://forums.digitalpoint.com/showthread.php?t=340315

second edit:
Here I've written a tutorial on how to create button mouse over effects if you're looking to do this...
http://www.supportforums.net/showthread.php?tid=1146

Yes, it does look like that, It seems like i am starting to no alot about dreamweiver Smile
[Image: wwsigcopy.jpg]
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)