Results 1 to 2 of 2

Thread: Dynamic Ajax Content-Page not Displaying second time clicked

  1. #1
    Join Date
    Jun 2006
    Posts
    12
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Dynamic Ajax Content-Page not Displaying second time clicked

    1) Script Title: Dynamic Ajax Content

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...jaxcontent.htm

    3) Describe problem: Page not Displaying second time clicked

    Hi Guys

    I have added the following code to automatically load a page from a menu/link call. The page in question loads ok the first time however if it is called again it is not displayed ie the user will need to manually select the page from the page

    the menu call is : customercare.asp?page=privacypolicy.htm
    and there are a number of such pages.

    My javascript knowledge is in an embryonic stage so I am not sure what to be looking for.

    I do not think I have changed the original Dynamic Ajax Content code.

    In head
    Code:
      <script language="JavaScript" type="text/JavaScript">
    function getQueryValue(name) {
        var match = (new RegExp('[?&;]' + name + '=([^&;#]*)')).exec(document.URL);
        return match ? unescape(match[1]) : null;
    }
    function loadstart(){
    var page = getQueryValue('page');
    if(page != null)
      {ajaxpage(page, 'thecontent');}
    else 
      {ajaxpage('privacypolicy.htm', 'thecontent');}
    }
    </script>
    in body

    Code:
    <body onLoad="javascript:window.print();">
    
    
    <script type="text/javascript">
    window.onload = loadstart();
    </script>
    thanks

    Moris

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Try this one instead of your getQueryValue():

    Code:
    function getQueryValue(key_str) {
    var query = window.location.search.substr(1);
    var pairs = query.split("&");
    for(var i = 0; i < pairs.length; i++) {
    var pair = pairs[i].split("=");
    if(unescape(pair[0]) == key_str)
    return unescape(pair[1]);
    }
    return null;
    }
    Yours looked a bit shaky to me but, I may just have misunderstood it.

    And, I'd get rid of this:

    Code:
    onLoad="javascript:window.print();"
    At best, it will be overriden by:

    Code:
    <script type="text/javascript">
    window.onload = loadstart();
    </script>
    at worst, who knows?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •