Welcome, Guest
Username: Password: Remember me

TOPIC: Exit iframe at end of survey

Exit iframe at end of survey 2 years 5 months ago #78143

  • Fred
  • Fred's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 163
  • Thank you received: 5
  • Karma: 3
Okay Javascript gurus, this must have been done before, but I couldn't find in the forum archives.

I have a survey in an iframe. When complete I want it to go to the end url, but at the same time exit the iframe. In other words, the link should become the parent window, not be displayed in the iframe.

I know there is a way to do this in javascript, but where would I put the function (template.js?) and how would I get get it called when they click the endurl (or when the survey is completed)? I definitely need the endurl because I'm passing some parameters through.

I was hoping not to have to go through some sort of intermediate page just to break out of the iframe.
The administrator has disabled public write access.

Re: Exit iframe at end of survey 2 years 5 months ago #78155

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4195
  • Thank you received: 789
  • Karma: 359
If you are displaying the end URL (instead of automatically loading it), you can use JS to change the target attribute of the link to "_top".

What template are you using?
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Exit iframe at end of survey 2 years 5 months ago #78156

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4195
  • Thank you received: 789
  • Karma: 359
Hmm...and maybe if you are automatically loading the end URL, you can add this script to a question on the last page. It will change the target of the form to "_top". I haven't tested this but it's worth a try.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		$('#limesurvey').attr('target', '_top');	
	});
 
</script>
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Exit iframe at end of survey 2 years 5 months ago #78241

  • Fred
  • Fred's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 163
  • Thank you received: 5
  • Karma: 3
Thanks Tony, I knew you would know something. I think the template is a variation of mint_idea, but we are going to switch or redesign it at some point.

If I want to change the attributes of the end url link, where does that go? I looked at the endpage in the template and don't see much happening there.
The administrator has disabled public write access.

Re: Exit iframe at end of survey 2 years 5 months ago #78254

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4195
  • Thank you received: 789
  • Karma: 359
To change the target of all links in the endpage, add the following to the end of endpage.pstpl:
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		$('a').attr('target', '_top');			
	});
 
</script>
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Exit iframe at end of survey 2 years 5 months ago #78264

  • Fred
  • Fred's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 163
  • Thank you received: 5
  • Karma: 3
Thanks Tony! That worked perfectly. I still owe you that beer if you are ever in Boston
The administrator has disabled public write access.

Re: Exit iframe at end of survey 4 months 2 days ago #108960

  • wwdetmb
  • wwdetmb's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 2
  • Karma: 0
tpartner wrote:
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		$('#limesurvey').attr('target', '_top');	
	});
 
</script>

This is exactly what I'd like to do - exit the iframe at the end of the survey - have the automatically loaded end URL load without the iframe. Tried this javascript but it didn't work for me (although the javascript to change the target of all links on the endpage DOES work).

I realize that this thread is 2 years old... is there a solution out there?

Thank you in advance!
Last Edit: 4 months 2 days ago by wwdetmb.
The administrator has disabled public write access.

Re: Exit iframe at end of survey 4 months 2 days ago #109004

  • wwdetmb
  • wwdetmb's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 2
  • Karma: 0
tpartner wrote:
Hmm...and maybe if you are automatically loading the end URL, you can add this script to a question on the last page. It will change the target of the form to "_top". I haven't tested this but it's worth a try.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		$('#limesurvey').attr('target', '_top');	
	});
 
</script>

This worked for me when placed in navigator.pstpl. Thanks!
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.135 seconds
Donation Image