SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2003
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Custom error handling script not working. :/

    Ok, i dont know crap about javascript, i'm the first to admit that, but i tried writing a function to handle errors from variables or whatever to use in other functions. Here is 2 functions i am using, so you can see what i am trying to do hopefully.

    PHP Code:
    <script language="JavaScript" type="text/javascript">
    <!--
     function 
    HandleError(arr) {
      var 
    displayError "";
      for(
    j=0j<arr.lengthj++) {
       if(
    arr[j] == "") {
        var 
    displayError = new Array();
        
    displayError[j] = arr[j];
       }
      }
      for(
    k=0k<displayError.lengthk++) {
       
    alert("JavaScript Error!\n\n The following error occurred:\n\n" displayError[k] + "\n\nThis variable or argument has generated an error.  This script has been aborted.");
      }
     }
     function 
    PopWindow(winURL,winNAME,winWIDTH,winHEIGHT) {
      var 
    arrArgs  = new Array(winURL,winNAME,winWIDTH,winHEIGHT);
      
    HandleError(arrArgs);
      var 
    winTOOLBAR  0;
      var 
    winMENUBAR  0;
      var 
    winSCROLLBARS 1;
      var 
    winDIRECTORIES 0;
      var 
    winSTATUS  0;
      var 
    winLOCATION  0;
      var 
    winRESIZABLE 0;
      var 
    winCONFIG  "width=" winWIDTH ",height=" winHEIGHT ",menubar=" winMENUBAR ",toolbar=" winTOOLBAR ",scrollbars=" winSCROLLBARS ",directories=" winDIRECTORIES ",status=" winSTATUS ",location=" winLOCATION ",resizable=" winRESIZABLE;
      
    window.open(winURL,winNAME,config=winCONFIG);
     }
    //-->
    </script> 
    then of course, i am calling my PopWindow() function like this...

    PHP Code:
     <a href="javascript:PopWindow('template.html','newWindow',400,800);">Open Window</a
    Now the handle error function just shows 'undefined' in the alert box, plus it alerts as many times as it finds a variable with a null value. any ideas on how to fix this or better ideas? i wish i knew javascript, but i dont.. i am just slowly getting bits and pieces...

  2. #2
    SitePoint Addict
    Join Date
    Mar 2002
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not really sure what's going on here. See if this helps:

    http://hotwired.lycos.com/webmonkey/...x4a_page2.html

    Nick
    All4YourPC for all your PC needs. Custom software.
    Websites. Web marketing. Training.
    http://members.aol.com/nickjc67


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •