Javascript is not my usual thing...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • squish54
    New Member
    • Jun 2007
    • 1

    Javascript is not my usual thing...

    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="MsoNorma l" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
    &nbsp;</p>
    <div style="CLEAR: both; MARGIN-TOP: -3%; postition: relative">
    <p class="MsoNorma l" 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>Orangebu rg, NY&nbsp; 10962</font></span></font></p>
    <p class="MsoNorma l" 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:
    [CODE=javascript]</style>
    <script language="JavaS cript">
    <!--
    function FP_swapImg() {//v1.0
    var doc=document,ar gs=arguments,el m,n; doc.$imgSwaps=n ew Array(); for(n=2; n<args.length;
    n+=2) { elm=FP_getObjec tByID(args[n]); if(elm) { doc.$imgSwaps[doc.$imgSwaps.l ength]=elm;
    elm.$src=elm.sr c; elm.src=args[n+1]; } }
    }

    function FP_preloadImgs( ) {//v1.0
    var d=document,a=ar guments; if(!d.FP_imgs) d.FP_imgs=new Array();
    for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image; d.FP_imgs[i].src=a[i]; }
    }

    function FP_getObjectByI D(id,o) {//v1.0
    var c,el,els,f,m,n; if(!o)o=documen t; if(o.getElement ById) el=o.getElement ById(id);
    else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
    if(o.id==id || o.name==id) return o; if(o.childNodes ) c=o.childNodes; if(c)
    for(n=0; n<c.length; n++) { el=FP_getObject ByID(id,c[n]); if(el) return el; }
    f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
    for(m=0; m<els.length; m++){ el=FP_getObject ByID(id,els[n]); if(el) return el; } }
    return null;
    }
    // -->
    </script>[/CODE]

    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
    Last edited by acoder; Jun 27 '07, 09:01 AM. Reason: Code in tags + removed bold tags
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    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

    Comment

    • eboyjr14
      New Member
      • Apr 2007
      • 27

      #3
      Try adding this JavaScript code right before the error:

      And next time,
      Use CODE tags around your code:
      Code:
      ..code goes here..
      Code:
      function getArgs(){
         var args = new Object();
         var query = location.search.substring(1);     // Get query string
         var pairs = query.split("&");                 // Split at ampersand
         search_array = query.split("&");     
         for (var i=0; i < pairs.length; i++){
             var pos = pairs[i].indexOf('=');          // Look for "name=value"
             if (pos == -1) continue;                  // If not found, skip
             var argname = pairs[i].substring(0,pos);  // Extract the name
             var value = pairs[i].substring(pos+1);    // Extract the value
             args[argname] = unescape(value);          // Store as a decoded value
         }
         return args;                                  // Return the object
      }

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        Heya, Squish.

        Originally posted by squish54
        [code=javascript]function FP_getObjectByI D(id,o) {//v1.0[/code]
        This version 1.0... must have been before the original developer discovered the return key :P

        Comment

        Working...