By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,461 Members | 1,108 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,461 IT Pros & Developers. It's quick & easy.

Javascript is not my usual thing...

P: 1
Hi folks - I am mastering a website and there was some pre-existing Java content that I'd like to keep. The problem is that there is an error in the code somewhere and I am more of a networking guy than a programmer. Could one of you code-meisters please take a look at this and point out the error & proper code to resolve the problem?

Here is the script:

[HTML]<SCRIPT type=text/javascript>
var oArgs = GetArgs("?");
if (oArgs["return"] == 'ok') {
document.write('<p style="color: red"><em>Your file has been successfully uploaded.</em></p>');
}
</SCRIPT>
</div>
</div>
</div>
</div>
</div>
</font></div>
</div>
</div>
<table cellSpacing="2" width="80%" border="0" id="table3">
<tr>
<td class="topics">
<div style="CLEAR: both; MARGIN-TOP: -3%; postition: relative">
<p class="MsoNormal" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
&nbsp;</p>
<div style="CLEAR: both; MARGIN-TOP: -3%; postition: relative">
<p class="MsoNormal" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font color="#CCFFCC" face="Verdana" size="2">
<br></font></p>
<p style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font color="#FFFFFF"><span class="eFooter">
<font face="Verdana"><font size="3">Hall &amp; Associates</font><br>560 Route 303, Suite 209<br>Orangeburg, NY&nbsp; 10962</font></span></font></p>
<p class="MsoNormal" style="line-height: 150%; margin-top: 0; margin-bottom: 0">&nbsp;</div></div>
</td>
</tr>
</table>
</center></td>
</tr>
</table>
</td>
</tr>
</table>
</center>

</body>

</html>
[/HTML]
When I show the details of the error in Internet Explorer, it says:
Line: 176
Char: 3
Error: Object expected
Code: 0

This is the line in question:
var oArgs = GetArgs("?");

There is a second script at the top of the page:
Expand|Select|Wrap|Line Numbers
  1. </style>
  2. <script language="JavaScript">
  3. <!--
  4. function FP_swapImg() {//v1.0
  5.  var doc=document,args=arguments,elm,n; doc.$imgSwaps=new Array(); for(n=2; n<args.length;
  6.  n+=2) { elm=FP_getObjectByID(args[n]); if(elm) { doc.$imgSwaps[doc.$imgSwaps.length]=elm;
  7.  elm.$src=elm.src; elm.src=args[n+1]; } }
  8. }
  9.  
  10. function FP_preloadImgs() {//v1.0
  11.  var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array();
  12.  for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image; d.FP_imgs[i].src=a[i]; }
  13. }
  14.  
  15. function FP_getObjectByID(id,o) {//v1.0
  16.  var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
  17.  else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
  18.  if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
  19.  for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
  20.  f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
  21.  for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } }
  22.  return null;
  23. }
  24. // -->
  25. </script>
This seems to have the "Args" value in there somewhere but like I said, it's all greek to me! Any help would be very much appreciated - thank you to all you coders out there. = )

Brian
Jun 26 '07 #1
Share this Question
Share on Google+
3 Replies


Expert 10K+
P: 11,448
This is a Javascript thing; not a Java thing (although the names look alike Java
has almost nothing to do with Javascript).

I'll move your question over to a Javascript forum.

kind regards,

Jos
Jun 26 '07 #2

eboyjr14
P: 27
Try adding this JavaScript code right before the error:

And next time,
Use CODE tags around your code:
Expand|Select|Wrap|Line Numbers
  1. ..code goes here..
Expand|Select|Wrap|Line Numbers
  1. function getArgs(){
  2.    var args = new Object();
  3.    var query = location.search.substring(1);     // Get query string
  4.    var pairs = query.split("&");                 // Split at ampersand
  5.    search_array = query.split("&");     
  6.    for (var i=0; i < pairs.length; i++){
  7.        var pos = pairs[i].indexOf('=');          // Look for "name=value"
  8.        if (pos == -1) continue;                  // If not found, skip
  9.        var argname = pairs[i].substring(0,pos);  // Extract the name
  10.        var value = pairs[i].substring(pos+1);    // Extract the value
  11.        args[argname] = unescape(value);          // Store as a decoded value
  12.    }
  13.    return args;                                  // Return the object
  14. }
Jun 27 '07 #3

pbmods
Expert 5K+
P: 5,821
Heya, Squish.

Expand|Select|Wrap|Line Numbers
  1. function FP_getObjectByID(id,o) {//v1.0
This version 1.0... must have been before the original developer discovered the return key :P
Jun 27 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.