Solved

deprecated arguments usage

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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

Suggested Solutions

Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
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…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…

734 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