Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
198
rated 0 times [  199] [ 1]  / answers: 1 / hits: 23164  / 12 Years ago, tue, april 24, 2012, 12:00:00

I may be asking the wrong question here so I will provide a small amount of detail about what I am trying to accomplish.



I use a third party web app to track support tickets. They provide the code for a form that my users fill out and it submits to their domain. I want to use this form on two different domains, but unfortunately the third party uses a single, hard coded redirect value. This causes one of my sites to switch domains after submission.



I was thinking I could embed their form in an iFrame, detect the redirection on successful form submission and instead redirect to one of my own pages.



Pseudocode:



iframe.detectRedirection
if (redirect == 'xyz.html') {
//do my own redirection in main window.
}


So back to my original question - how can I detect the redirection in the iframe?


More From » jquery

 Answers
198

You could try



$(iframe).load(function(){
//The iframe has loaded or reloaded.
});


to detect the frame loading and refreshing



and if the redirect happens on the second load



//var to count times iframe has loaded
var timesRefreshed = 0;

//detect iframe loading/refreshing
$(iframe).load(function(){

//if second refresh, change frame src - ie dont count first load
if(timesRefreshed == 1){
$(this).attr(src,my site url here);
}

//add to times resreshed counter
timesRefreshed++;

});


if there are more stages just change the x to the amount of stages



if(timesRefreshed == x)


this isnt full proof. ie if could break if the other site adds a stage etc but its the best i can think of if you dont have any control over the other site.


[#86013] Monday, April 23, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
harveys

Total Points: 113
Total Questions: 88
Total Answers: 79

Location: Oman
Member since Fri, Dec 23, 2022
1 Year ago
;