Solved

deprecated arguments usage

Posted on 2006-11-12
4
1,551 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
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:
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

912 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

25 Experts available now in Live!

Get 1:1 Help Now