?
Solved

deprecated arguments usage

Posted on 2006-11-12
4
Medium Priority
?
1,625 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 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
Strategic internal linking is often considered an SEO power technique, especially for content marketing. Do you need to hire an SEO agency to optimize you internal linking? No, this article will help you understand the basics of internal linking and…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
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).
Suggested Courses
Course of the Month13 days, 16 hours left to enroll

809 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