Solved

deprecated arguments usage

Posted on 2006-11-12
4
1,588 Views
Last Modified: 2008-04-29
the javascript debugger is reporting this warning: deprecated arguments usage
Source File: http://www.site.com/scripts/global.js
Line: 76

function MM_preloadImages()
{
      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;    <<<<<<<<< this line

            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];
                  }
      }
}

since its deprecated, what is the fix.
0
Comment
Question by:ellandrd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 23

Expert Comment

by:rama_krishna580
ID: 17925945
Hi,

you will need to insert the following code in to the head of the document:

<script language="JavaScript" type="text/JavaScript">

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];}}

edit:
the one the Tweny posted is good too, but he must have been posting at the same time as me. :) i think his a little more complex though. mine just sounds a littel harder becuase i gave such detailed instructions on how to use it. LoL. well, use either one. hope you can figure it out from there.
}

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>


and you will need the following code for the button


<body onLoad="MM_preloadImages('PATH/FILENAME_ON_OVER.EXTENSION','PATH/FILENAME_ON_PRESS.EXTENSION')">
<a href="LINK HERE" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image1','','PATH/FILENAME_ON_OVER.EXTENTION',1)" onMouseDown="MM_swapImage('Image1','','PATH/FILENAME_ON_PRESS.EXTENTION',1)"><img src="PATH/ORIGINAL_IMAGE_FILENAME.EXTENSION" name="Image1" border="0"></a>
</body>


note that i use a preload image in the body tag to preload the images. you will obviously need to change "PATH/FILENAME_ON_OVER.EXTENSION" to something like "images/photo1b.jpg" and "PATH/FILENAME_ON_PRESS.EXTENSION" to something like "images/photo1c.jpg". this will preload the rollover image and the pressed image. :)

also make sure to change "PATH/FILENAME_ON_OVER.EXTENSION" and "PATH/FILENAME_ON_PRESS.EXTENSION" in the link where it says "onMouseOver" "and onMouseDown" onMouseOver is where the rollover image will go, and onMouseDown is where the pressed image will go. Make sure to change "PATH/ORIGINAL_IMAGE_FILENAME.EXTENSION" to the original file name. something like "images/photo1a.jpg"

http://www.dynamicdrive.com/forums/archive/index.php/t-6873.html
http://www.dynamicdrive.com/forums/showthread.php?t=6873
http://portal.aauj.edu/portal_resources/downloads/multimedia/flashmx_actionscript_ebook.pdf 
http://esdi.excelsystems.com/userguides/WebsmartReferenceGuide.pdf

I hope this helps. let me know if you need any more help with it. :)

R.K
0
 
LVL 6

Accepted Solution

by:
aescnt earned 500 total points
ID: 17927320
rama_krishna500, those still seem to have the "deprecated call" of using `arguments` as a property to the function.

After reading the Mozilla MDC link posted by gamebits, I think the fix is more of replacing the line:
          var i,j=d.MM_p.length,a=MM_preloadImages.arguments;

with:
          var i,j=d.MM_p.length,a=(arguments ? arguments : MM_preloadImages.arguments);

Hope this helps. As a lateral thought, I would suggest researching into making those rollovers with CSS so it won't depend on JS code.
0
 
LVL 6

Expert Comment

by:aescnt
ID: 17927329
*rama_krishna580, sorry. little typo on the name there.
0

Featured Post

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question