Ajax Pagination not working with iframe

Posted on 2008-11-05
Last Modified: 2013-11-11

My site  implements pagination of search results using mootools v1.11 pagination. Basically, the index.php  page with a search box has a div that looks like this:

<div id="pagecontainer">
          <ul class="paginater" id="rtable-tablePaginater">

followed by a table like this: <table id="rtable">

A script tag references the .js file.

The search has worked fine till now. However, if I add an iframe anywhere in the index.php file, it breaks the pagination in the .js file. As the javascript code is obfuscated it is hard to debug, but I know for sure that when it works, a javascript object is created with the classname = "paginater" and id = "rtable-tablePaginater", as you would expect.

However, when an iframe is added to index.php, that same object in the .js file is created but with different properties, without the classname or id, and causes the pagination to hang.

I've tried many tests and it seems that iframes are the problem.

Please let me know if further clarification or description of the problem is required.
Question by:timoteo70

    Author Comment

    After more testing, it seems that the object that is created when I am using an iframe is of type Window, when in fact it should be a javascript object is created with the classname = "paginater" and id = "rtable-tablePaginater".

    Somewhere in the process the creation of an iframe is causing an incorrect Window object to be created.

    Accepted Solution

    I guess I'm edging closer to finding the exact cause of the problem.

    Instead of adding the iframe in the main index.php file using the iframe tag, I added it like this:

                alert("creating iframe");      
                   ifrm = document.createElement("IFRAME");
                   ifrm.setAttribute("src", "");
          = 640+"px";
          = 120+"px";
       = 300+"px";
       = 300+"px";

    This doesn't cause a problem with the AJAX pagination. However, when I add the line:


    that's when the AJAX code breaks. Looking at the javascript code there are dozens of references to the appendchild and even a firstchild function. Perhaps when I add the iframe as a child to document.body I am screwing with the expected order of the document children.

    Is there a way I can change the order of the document children? That is, if the iframe child is the first child, can I make it the last?

    Hope that makes sense.

    By the way, I'll be happy to share the code with an expert who thinks they might be able to work with me to get a solution, I just cannot  paste it all here publicly.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Introduction HyperText Transfer Protocol ( or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
    Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now