...

View Full Version : iframe onLoad function lost with replace() method



eddjc
05-27-2009, 09:32 AM
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:


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:


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

eddjc
05-27-2009, 11:04 AM
Hey all, worked it out. Sorry - onload wasn't lost, I just hadn't fully converted the code to the different method!

Cheers
Edd



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum