Help needed with this Javascript
Can anyone tell me what this javascript do and how to use it? If you know what it does can give me an example of how to use it? Thanks.
<script language="JavaScript" type="text/JavaScript">
<!--
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_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_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];}
}
//-->
</script>
They are four badly written functions generated out of Dreamweaver. The function names give an indication of what they do.
preload images
restore swapped image
find object
swap image
The actual code to perform those functions only really needs to be about 1/3 of what is there but then WYSIWYG editors are not the best way of generating JavaScript.
Thanks Stephen. I found the next code on cams.com by looking at there source code. Maybe that would be a better example. How would I use this on a website? Thanks.
<script language="Javascript">
var ie7 = 0;
if (window.XMLHttpRequest && window.ActiveXObject) {
ie7 = 1;
}
var poptest = null;
if (window.SymRealWinOpen){
window.open = SymRealWinOpen;
}
if (window.NS_ActualOpen){
window.open = NS_ActualOpen;
}
function blockError(){
//alert("Block Error");
return true;
}
window.onerror = blockError;
function bypass(){
window.onfocus=null;
// alert("BY PASS");
if (ie7 == 0) poptest = window.showModelessDialog("javascript :function blockError(){return true;} window.onerror = blockError; function pop(){setTimeout(\"self.blur(); self.parent.focus(); top.location.href='http://adultfriendfinder.com/go/g106.subpop1?mustgounder=1'; self.close(); self.opener.focus(); self.parent.focus(); \",2);} pop(); self.blur(); self.parent.focus(); self.parent.focus();","","dialogtop=9999; dialogleft=9999; dialogheight:0px; dialogWidth:0px; dialogHide:1; resizable: 1; status:no; help:no;scroll:yes;status:yes");
else poptest = window.showModelessDialog("http://adultfriendfinder.com/go/g106.subpop1?mustgounder=1");
poptest.innerHeight = "400";
poptest.height = "400";
poptest.innerWidth = "600";
poptest.width = "600";
poptest.blur();
poptest.parent.focus();
poptest.window.opener.focus();
}
var from_pop = 0;
if (from_pop != 1) {
poptest = window.open('http://adultfriendfinder.com/go/g106.subpop1?mustgounder=1','poptest','location=yes,scrollbars=yes,menubar=yes,toolbar=yes,resizable=yes,screenX=0,screenY=0,height=400,width=600');
if(!poptest){
window.onfocus=bypass;
window.focus();
}
poptest.blur();
window.focus();
}
</script>
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks