Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2008
    Posts
    104
    Thanks
    4
    Thanked 14 Times in 14 Posts

    iframe onLoad function lost with replace() method

    Hi there,

    I've been using a hidden iframe for remote server scripting - how i've been doing it is that a load(); function changes the src component of the iframe with $_GET variables to pass to PHP:

    Code:
    this.load = function () {
    	
    		
    		
    		this.iframe.src = this.file + "?action=load&gid=" + this.gid + "&last_modified=" + this.last_modified;
    		
    	
    	}
    The frame itself then has an "onload" function that calls a doLoad(); function that handles receipt of any information back from the server. declared this way:

    <iframe id="loader" onload="loader.doLoad();" style="width:0px;height:0px;border:none;"></iframe>

    The trouble with this as you may guess is that the page was reloading every time src was changed and the history list of the browser was messed up. So I did some research and came up with this method that solves that problem:

    Code:
    this.load = function () {
    	
    		//this.iframe.src = '';
    		
    		this.iframe.contentWindow.document.location.replace(this.file + "?action=load&gid=" + this.gid + "&last_modified=" + this.last_modified);
    		
    	
    	}
    Which is great, but now onload doesn't call! Any ideas for a replacement?

    Thanks
    Edd

  • #2
    Regular Coder
    Join Date
    Aug 2008
    Posts
    104
    Thanks
    4
    Thanked 14 Times in 14 Posts
    Hey all, worked it out. Sorry - onload wasn't lost, I just hadn't fully converted the code to the different method!

    Cheers
    Edd


  •  

    Posting Permissions

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