Close lightbox

All WYSIWYG Web Builder support issues that are not covered in the forums below.
Forum rules
PLEASE READ THE FORUM RULES BEFORE YOU POST:
viewtopic.php?f=12&t=1901

MUST READ:
http://www.wysiwygwebbuilder.com/getting_started.html
WYSIWYG Web Builder FAQ
User avatar
Billywiz
 
 
Posts: 231
Joined: Thu Jul 17, 2008 3:32 pm
Location: UK
Contact:

Re: Close lightbox

Post by Billywiz » Sun Jun 21, 2020 10:06 am

Thanks Roger,
Let me run through what I have done and you can tell me if its correct.
On the success page that opens in the lightbox I have added a timer set to 4 seconds, in events within the timer I have selected "On timer" run javascript and placed the code you gave me but it doesnt close the lightbox.
If you go to https://www.summitcarhire.com/test and click the link at the bottom of the page "Can we improve, let us know" a lightbox pops up, just tick the recaptcha and a success page comes up thanking the visitor for the feedback, I then want that lightbox to close after 4 seconds so that all the visitor sees is the original index page that they clicked the link on.
Thanks for your input.

Cheers
The Cheapest Car Hire, Worldwide.

Summit Car Hire

User avatar
rogerl
 
 
Posts: 291
Joined: Tue May 03, 2016 8:24 am

Re: Close lightbox

Post by rogerl » Sun Jun 21, 2020 11:18 am

The lightbox you open for success has a settings button.
Try this code in there:

Code: Select all

'onComplete': function(){
    setTimeout( function() {$.fancybox.close(); },4000); // 4000 = 4 secs
  }
and remove the event / timer stuff then preview and see what happens. You could upload your test project (.wbs file) and give me alink to it so I can have a play. It's one step at a time till it all comes right.

User avatar
Billywiz
 
 
Posts: 231
Joined: Thu Jul 17, 2008 3:32 pm
Location: UK
Contact:

Re: Close lightbox

Post by Billywiz » Sun Jun 21, 2020 1:12 pm

Hi Roger, I think there may be some confusion here, there is only 1 lightbox and that opens from the link on ther index page, all other pages open in that lightbox, not seperate lightboxes. If I alter any settings then I can only do it in the link on the index page by choosing the "open in a lightbox"

Cheers
The Cheapest Car Hire, Worldwide.

Summit Car Hire

User avatar
rogerl
 
 
Posts: 291
Joined: Tue May 03, 2016 8:24 am

Re: Close lightbox

Post by rogerl » Sun Jun 21, 2020 10:37 pm

Yes, do it there then. If I could see your project file I would know better how to help.

User avatar
Billywiz
 
 
Posts: 231
Joined: Thu Jul 17, 2008 3:32 pm
Location: UK
Contact:

Re: Close lightbox

Post by Billywiz » Mon Jun 22, 2020 8:35 am

Hi Roger, I have done the project with only the problem elements remaining.
You can see the altered website at https://www.summitcarhire.com/testing
You can download the zip at https://www.summitcarhire.com/wbs/june2020.zip
When the page with "Thankyou for your feedback" appears I want that to close after 4 seconds so that all that's visible is the index page.

Cheers
The Cheapest Car Hire, Worldwide.

Summit Car Hire

User avatar
rogerl
 
 
Posts: 291
Joined: Tue May 03, 2016 8:24 am

Re: Close lightbox

Post by rogerl » Tue Jun 23, 2020 2:12 am

Far easier to see what's happening with the project file, thanks for that. I think this is best handled in the "success" page that could execute a script after page load in the light box. Will have a play later today.

lac8383
 
 
Posts: 27
Joined: Sun Mar 24, 2019 6:34 pm

Re: Close lightbox

Post by lac8383 » Tue Jun 23, 2020 3:42 am

Guys,
This seems to be harder than expected to resolve. From all the searches I looked at over the weekend regarding closing pop-ups, parent processes from a main page that kick off child processes such as opening a lightbox which open another page (e.g. success page) is another child process. Trying to do windows.close(), windows.parent.close() functions and similar haven't worked in my testing.

From what I read in an article or two "Scripts may not close windows that were not opened by script" (https://medium.com/javascript-in-plain- ... eec56344bb) and (https://developer.mozilla.org/en-US/doc ... ndow/close).
In testing using a timer in the Success page to run javascript to do say a windows.close() function, pressing F12 in the browser would give the results: "Scripts may close only the windows that were opened by them".

I would guess that knowing the parent and child process ID's and being able to do a close function on the desired one would work. For example, the main page with the survey link would be the parent, the child would be the lighbox, and another child would be the success page.

I'm sure closing the lightbox automatically can be done but may require some additional javascript coding to make it functional. Unfortunately, I don't have javascript experience to help in this matter.
If you find a solution, I would love to see how it was done.

Regards,
Leo

User avatar
rogerl
 
 
Posts: 291
Joined: Tue May 03, 2016 8:24 am

Re: Close lightbox

Post by rogerl » Tue Jun 23, 2020 10:22 am

Hi Guys,
I believe I have had success!
Couple of things to start:
In page properties for "Survey.php" the default lightbox is not fancybox
In error and success pages it does not have access to jquery or fancybox scripts and there is the complication of child verses parent as outlined above.
I found a script which appears to do the job and this should be inserted in page html, Between <head> and </head> tags on the "error" and "success" pages. Have timeout set to 2 seconds here:

Code: Select all

<script>
 
  (function(){
  
    // Your URL
    var url = 'index.html';
  
    // Delay before the redirect takes place, in seconds
    var delay = 2;
    
    window.setTimeout(function() {
     window.open(url, '_parent');
    }, delay * 1000);
  
  })();
 
</script>
On my test site I have set up for the success page only. Please see:
-- Link removed --
What do you think?
Regards
Roger
Last edited by rogerl on Tue Jun 30, 2020 11:51 pm, edited 2 times in total.

User avatar
Billywiz
 
 
Posts: 231
Joined: Thu Jul 17, 2008 3:32 pm
Location: UK
Contact:

Re: Close lightbox

Post by Billywiz » Tue Jun 23, 2020 12:15 pm

Hi Guys,
Leo, Roger has cracked it, Happy Days !!

Roger, thank you for your hard work figuring out this task, it works like a dream. I tweaked the code on the error page so that the visitor is taken back to the survey within the lightbox by changing _parent to _self.
Thanks again, it has saved me from opening the survey in a popup which I was reluctant to do.

Cheers
The Cheapest Car Hire, Worldwide.

Summit Car Hire

User avatar
rogerl
 
 
Posts: 291
Joined: Tue May 03, 2016 8:24 am

Re: Close lightbox

Post by rogerl » Tue Jun 23, 2020 12:23 pm

Enjoyed the challenge, not the frustration!
Thanks for the other update for the error page, that will be useful for something I'm working on as well.

User avatar
rogerl
 
 
Posts: 291
Joined: Tue May 03, 2016 8:24 am

Re: Close lightbox

Post by rogerl » Tue Jun 30, 2020 11:59 pm

Hi Guys,
A further to as I had a play the other night knowing this would be useful for my site.
I have a common error page called from multiple forms so needed to adapt the script to accommodate that and use your "_self" amendment. So ended up with this:

Code: Select all

<script>
 
  (function(){
  
    // Your URL
    var url = document.referrer;
  
    // Delay before the redirect takes place, in seconds
    var delay = 4;
    
    window.setTimeout(function() {
     window.open(url, '_self');
    }, delay * 1000);
  
  })();
 
</script>
Works great!

Post Reply