I am using the following line to kick off main.php which loads an iframe:
window.location.href = '/main.php?token='+obj.token;
I need to wait for the iframe to complete loading so the $_GET token can be obtained.
After this I want to run the below line to remove the token from the command line:
window.history.pushState("object or string", "Title", "/new-url");
At the moment pushState always fires to quickly and then token is lost.
Is there a way to delay this until the iframe is completely loaded?
Don’t want to use a timer as it might not work sometimes.
thx
you can bind to the
readyevent of the iframe like so:where
frametestis the id of your iframe.Here is a jsfiddle for this:
http://jsfiddle.net/fQB2H/1/