Solved

deprecated arguments usage

Posted on 2006-11-12
4
1,546 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
  • 2
4 Comments
 
LVL 28

Expert Comment

by:gamebits
ID: 17925884
0
 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Uploading files to the web server has become common part of almost any kind of web application. People use different technologies to solve this, but regardless of the technology used, it is always useful to have some kind of progress indicator shown…
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now