Submit Your Article Forum Rules

Results 1 to 3 of 3

Thread: Baffling JS error

  1. #1
    Moderator chrisJumbo's Avatar
    Join Date
    Oct 2005
    Location
    Near Sacramento, CA
    Posts
    788

    Baffling JS error

    For starters this is not all my code. I took the graphing code and then mingled in calls to load the graphs in an Iframe. The only problem I have is when I click the button to view the graph in the Iframe vs. the links on the page that load a different graph. The problem I am having is when the button is used (at least in FF), the page continues to show the "still loading" symbol. It appears that the code is waiting for something or for some reason FF thinks it isn't finished.

    The page it happens on is www.jumbocdinvestments.com/historicalcdrates.htm

    Also, this code is old, but it is what I am familiar with. I've been updating the data and noticed the behavior. It is just bugging me.

    After you load the page, click the link that says, "Show Raw Data" that is in the IFrame, on the graph. Now click the button that says, Graph. The page continues to give the symbol that it is still loading.

    Here is some of the code. From the Raw Data page (html):
    Code:
    <div id="buttonA" onClick="showGraph1y();">
    <ul><li class="buttonli" onMouseOver="this.className='buttonlib'" onMouseOut="this.className='buttonli'">Graph Data</li></ul></div>
    And some of the code from the JS file:
    Code:
    function loadIframeG(iframeName, fnc) {
      if (typeof fnc == 'undefined' ) fnc = '';
      if ( window.frames[iframeName] ) { 
       	window.frames[iframeName].document.close();  	
    	if (fnc != '') {
    		switch (fnc) {
    			case '6m': showGraph6m(iframeName); break;
    			case '1y': showGraph1y(iframeName); break;
    			case '2y': showGraph2y(iframeName); break;
    			case '3y': showGraph3y(iframeName); break;
    			case '4y': showGraph4y(iframeName); break;
    			case '5y': showGraph5y(iframeName); break;
    
    			case '93': showGraph1993(iframeName); break;
    			case '94': showGraph1994(iframeName); break;
    			case 'o5': showGraph2005(iframeName); break;
    			case 'o6': showGraph2006(iframeName); break;
    			case 'o7': showGraph2007(iframeName); break;
    			case 'o8': showGraph2008(iframeName); break;
    			case 'o9': showGraph2009(iframeName); break;
                      case '10': showGraph2010(iframeName); break;
    			case '11': showGraph2011(iframeName); break;
    			case 'avg': showGraphAlly(iframeName); break;
    		}
    		window.frames[iframeName].document.close(); 
    
    	}
        return false;
      }
      else return true; 
    }	
    
    function showGraph1y(ifn)
    {
    if (typeof ifn == 'undefined' ) ifn = '';
    
    if (ifn != '') {
    var a = window.frames[ifn].document;
    }
    else {
    var a = this.document;
    }
    var g = new Graph(490,275);
    
    a.write("<a href='http://www.jumbocdinvestments.com/wp-content/themes/jumbocdinvestments.2011/historical-rates/1ycdrates.htm'>Show Raw Data</a>");
    g.addRow(4.033,5.223,6.311,5.889,6.136,5.728,5.871,7.091,4.586,2.956,2.054,2.674,4.188,5.404,5.443,3.933,1.920,1.077,0.706,0.639,4.091);
    g.scale = .5;
    g.setXScaleValues("1993","1994","1995","1996","1997","1998","1999","2000","2001","2002","2003","2004","2005","2006","2007","2008","2009","2010","2011","2012","Avg");
    g.title = "1Y Average Rates by Year";
    g.yLabel = "% APR";
    g.dLabel = true;
    g.build(a);
    }
    And code from where the page is first loaded:
    Code:
    <SCRIPT type="text/javascript" src="http://www.jumbocdinvestments.com/wp-content/themes/jumbocdinvestments.2011/historical-rates/ifram.js"></script>
    
    
    <h3>Historical CD Rates By Year</h3>
    <a href="http://www.jumbocdinvestments.com/wp-content/themes/jumbocdinvestments.2011/historical-rates/1993cdrates.htm" onclick="return loadIframeG('ifrm','93')">1993</a>,
    Seems to me it has to be something simple or I would have figured it out already. My mantra, the longer it takes to fix, the simpler the error seems to be coming true. Thank you for any suggestions.

    cd :O)

  2. #2
    Administrator weegillis's Avatar
    Join Date
    Oct 2003
    Posts
    5,785
    Chris, in Win 7, FF 14.0.1 I'm not seeing the problem you describe. The Raw Data and Graph are swapping in and out perfectly.

    <edit>

    Now I see what you mean, the page load indicator. There is no indication of anything hanging in the console. What's weird is if when you refresh the page with the graph it finishes loading. This is a prickly pear!

    </edit>

  3. #3
    Moderator chrisJumbo's Avatar
    Join Date
    Oct 2005
    Location
    Near Sacramento, CA
    Posts
    788
    And the refresh works because it reloads the page, which is a different function call. When the links are used on the page (note the frame), the frame ID is passed as a parameter so the functions know where to load the graph. When called from the frame, no id is passed.

    I'll keep playing around with it. :O)

Posting Permissions

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