Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Exit iframe at end of survey

  • Fred01
  • Fred01's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
11 years 11 months ago #78143 by Fred01
Exit iframe at end of survey was created 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.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
11 years 11 months ago #78155 by tpartner
Replied by tpartner on topic Exit iframe at end of survey
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.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
11 years 11 months ago #78156 by tpartner
Replied by tpartner on topic Exit iframe at end of survey
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.
Code:
<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.
The topic has been locked.
  • Fred01
  • Fred01's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
11 years 11 months ago #78241 by Fred01
Replied by Fred01 on topic Exit iframe at end of survey
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 topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
11 years 11 months ago #78254 by tpartner
Replied by tpartner on topic Exit iframe at end of survey
To change the target of all links in the endpage, add the following to the end of endpage.pstpl:
Code:
<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.
The topic has been locked.
  • Fred01
  • Fred01's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
11 years 11 months ago #78264 by Fred01
Replied by Fred01 on topic Exit iframe at end of survey
Thanks Tony! That worked perfectly. I still owe you that beer if you are ever in Boston
The topic has been locked.
More
9 years 9 months ago - 9 years 9 months ago #108960 by wwdetmb
Replied by wwdetmb on topic Exit iframe at end of survey

tpartner wrote:

Code:
<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: 9 years 9 months ago by wwdetmb.
The topic has been locked.
More
9 years 9 months ago #109004 by wwdetmb
Replied by wwdetmb on topic Exit iframe at end of survey

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.

Code:
<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 topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose