Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 665145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:40:39+00:00 2026-05-13T23:40:39+00:00

Tried to make a little old school ajax (iframe-javascript) script. A bit of mootools

  • 0

Tried to make a little old school ajax (iframe-javascript) script. A bit of mootools is used for DOM navigation

Description:

HTML:

1 iframe called “buffer”

1 div called “display”

JAVASCRIPT: (short: copy iframe content into a div on the page)

1) onLoad on iframe triggers handler(), a counter makes sure it only run once
(this is because otherwise firefox will go into feedback loop. What i think happens: iframe on load > handler() > copyBuffer > change src of iframe , and firefox takes that as an onload again)

2) copybuffer() is called, it sets src of iframe then copies iframe content into div, then erases iframe content

THE CODE:


count=0;
function handler(){

if (count==0){
copyBuffer();
count++;
}

}

function copyBuffer(){


$('buffer').set('src','http://www.somelink.com/');

if (window.frames['buffer'] && $('display') ) { 

$('display').innerHTML = window.frames['buffer'].document.body.innerHTML;
window.frames['buffer'].document.body.innerHTML="";
}

}

problems:

QUESTION 1) nothing happens, the content is not loaded into the div. But if i either:

A) remove the counter and let the script run in a feedback loop: the content is suddenly copied into the div, but off course there is a feedback loop going on, you can see it keeps loading in the status bar.

OR

B) insert an alert in the copyBuffer function. The content is copied, without the feedback loop.

why does this happen?

QUESTION 2) The If wrapped around the copying code i got from a source on the internet. I am not sure what it does? If i remove it the code does not work in: Safari and Chrome.

Many thanks in advance!


UPDATE:

Like the answers said i have created an event handler. They used jQuery, i have made one in mootools:

window.addEvent('domready', function() {

    $('buffer').addEvent('load', function(){

        $('display').set('html',window.frames['buffer'].document.body.innerHTML) 
        window.frames['buffer'].document.body.innerHTML="";

    }).set('src','somelink');

});

Bonus question:

3) Im new at stackoverflow (what an amazing place!), is it better if i make new threads for follow up questions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T23:40:39+00:00Added an answer on May 13, 2026 at 11:40 pm

    The iframe has not loaded the page when you try to access it, so it cannot get the contents..

    I believe the following would work, by adding a load handler on the iframe and do the copy inside that..

    function handler(){
       $('buffer').load( function(){copyBuffer();} ).attr('src','http://www.somelink.com/');
    }
    
    function copyBuffer(){
       if (window.frames['buffer'] && $('display') ) 
        { 
           $('display').innerHTML = window.frames['buffer'].document.body.innerHTML;
           window.frames['buffer'].document.body.innerHTML="";
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might get a little confusing as I have tried everything to make this
I'm trying to use Ajax together with jQuery to make a little window pop
I would like to make R a little bit easier to execute system command.
I tried to make an alert popup with A with: var a = \u0041;
I tried to make a layout look like it It looks like kinda button
I tried to make an asynchronous UDP client using boost::asio I get some code
I tried to make a click counter in MySQL, but it dose not seem
I tried to make my textbox type in currency format. I did it, but
I tried to make a new bare git repository but I get this error:
I tried to make admin panel and I am using sessions , but have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.