Check out the LimeSurvey source code on GitHub!

Exit iframe at end of survey

More
4 years 10 months ago #78143 by Fred01
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.

Please Log in to join the conversation.

More
4 years 10 months ago #78155 by tpartner
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.

Please Log in to join the conversation.

More
4 years 10 months ago #78156 by tpartner
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.

Please Log in to join the conversation.

More
4 years 10 months ago #78241 by Fred01
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.

Please Log in to join the conversation.

More
4 years 10 months ago #78254 by tpartner
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.

Please Log in to join the conversation.

More
4 years 10 months ago #78264 by Fred01
Thanks Tony! That worked perfectly. I still owe you that beer if you are ever in Boston

Please Log in to join the conversation.

More
2 years 9 months ago - 2 years 9 months ago #108960 by wwdetmb

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: 2 years 9 months ago by wwdetmb.

Please Log in to join the conversation.

More
2 years 9 months ago #109004 by wwdetmb

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!

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form