Welcome to the LimeSurvey Community Forum

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

Limesurvey in Iframe - hide iframe after survey is submited

  • LurLur
  • LurLur's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 months 2 weeks ago #254277 by LurLur
Please help us help you and fill where relevant:
Your LimeSurvey version: LimeSurvey Community Edition Version 6.3.6+231120
Own server or LimeSurvey hosting: Own server
Survey theme/template: fruity_twentythree
==================
Hi everyone,
I am sure this is possible but I just don't know where to add the code for it.
I run limesurvey on my own website and want to show the survey in an iframe (which works).
However, I also want to hide this iframe once the user submitted the survey. Where can i change some file in lime survey to do that?
I guess it has to do with the moveSubmit button but I can't find where the submit is handled.
Best
LurLur

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 months 2 weeks ago #254299 by holch
This is not a Limesurvey issue, but rather a HTML issue or an issue of your website. Limesurvey just shows up in your iframe, that's it. To close / hide the iframe, you need to do through your website, e.g. set a cookie and based on the cookie you show/hide the iframe with the survey. You won't find a setting for this in Limesurvey, because there is no setting in limesurvey and there can't be a setting in Limesurvey. The site shown in an iframe has no control over the iframe. This would be a serious security issue. Imagine a website that is shown within an iframe could manipulate your website.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

  • LurLur
  • LurLur's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 months 2 weeks ago - 3 months 2 weeks ago #254300 by LurLur
Thx for the quick reply,
however I think you misinterpreted my question (maybe I am in the wrong sub forum?):
I am not searching for a setting in limesurvey.  I want to find the code/file where the action of the submit button is defined so I can adjust this code to also close the iframe. Both pages are hosted by me, it is not a kind of crosssite scripting.
(see stackoverflow.com/questions/14645647/sub...nd-show-a-hidden-div for something similar for what I want to achieve)
Last edit: 3 months 2 weeks ago by LurLur.

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 months 2 weeks ago #254303 by holch
You are right, I missinterpreted your question.

However, while not a Javascript expert, I am not sure if you will be able to manipulate your website (where the iframe is) from within the iframe, e.g. when clicking on the submit button close the iframe. I still think this would be a security issue.

Let's see if Tpartner shows up, he is surely the expert for those things that involve Javascript for example.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 months 2 weeks ago - 3 months 2 weeks ago #254316 by tpartner
Since there should be no cross-domain issues, try this in the source of a question in the last survey group. (but test that the survey actually submits)

Code:
<script type="text/javascript" data-author="Tony Partner">
    $(document).on('ready pjax:scriptcomplete',function(){
 
        $('#limesurvey').on('submit', function(e) {
            top.document.getElementById("myiframe").style.display="none";
        });   
    });
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 3 months 2 weeks ago by tpartner.
The following user(s) said Thank You: DenisChenu, holch

Please Log in to join the conversation.

  • LurLur
  • LurLur's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 months 2 weeks ago #254318 by LurLur
Thanks,
this worked with a little tweak instead of hiding it, it set height and width to 0.
Thx a lot!

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 months 2 weeks ago #254321 by holch
Tpartner to the rescue again!

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

  • LurLur
  • LurLur's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 months 4 days ago - 3 months 4 days ago #254899 by LurLur
A quick follow-up question: Is there a possibility to adjust the code slightly, because right now the iframe will be closed, even if some mandatory question is not answered when pressing submit.
Last edit: 3 months 4 days ago by LurLur.

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 months 4 days ago - 3 months 4 days ago #254906 by DenisChenu

Since there should be no cross-domain issues, try this in the source of a question in the last survey group. (but test that the survey actually submits)
 
since we need it only after submit : why not, in end text content
Code:
<script>
top.document.getElementById("myiframe").style.display="none";
</script>

But in general what i do i create a jquery function in parent : something like
Code:
$(document).on('survey:submitted', function() {
// hide, remove, replace iframe
});
and inside iframe
Code:
window.parent.$(window.parent.document).trigger('survey:submitted');

See : gitlab.com/SondagesPro/QuestionSettingsT...ssets/extraSurvey.js
 and gitlab.com/SondagesPro/QuestionSettingsT...nExtraSurvey.js#L169

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Last edit: 3 months 4 days ago by DenisChenu.

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose