MBurleson Posted June 6 Share Posted June 6 So I have Lightbox anything loading a page on my site, on the page I have some content and then this code: <script type="text/javascript"> setTimeout(openUrl, 1500); function openUrl() {window.open('https://secure.cpteller.com/terminal/portal/?op=9LkVp0Ko0lLQ', '_blank');} </script> So the pop-up loads and then opens a blank page with the URL redirect. My issue is, once the link has been clicked and poped-up and then closed, if it is clicked again, the java script won't initialize again. I am not sure how to make it refresh and run the code every time the link in the website's nav is clicked. Thoughts? Link to comment
creedon Posted June 6 Share Posted June 6 Please post the URL for a page on your site where we can see your issue. A link to the backend of the your site won’t work for us, i.e. a url that contains /config/. Please set up a site-wide password, if your site is not public and you've not already done so. Post the password here. Adding a site-wide password does not allow anyone to alter your site. It only allows those with the password to see your site. Please read the site-wide password and how to share a link documentation to understand how they work. We can then take a look at your issue. You may find How to post a forum question post useful. Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects. Link to comment
MBurleson Posted June 12 Author Share Posted June 12 The page is talala.squarespace.com and the password is OMAG. The specific link is the one in the Nav header that says pay online. You can see when you click on the link, it opens a lightbox anything pop-up that then runs a javascript cod eon the page to open a new window to a specific URL. Link to comment
creedon Posted June 12 Share Posted June 12 I'm a little confused by the flow the user is being put through. Wouldn't it be easier to have the pay online link just open the payment processor page directly? Instead of a trip through the lightbox window and redirect code? If your goal is to get the pay online link to open in a new window that could be accomplished without the lightbox anything and redirect. If I've misunderstood the importance of the lightbox anything use in this case please give us more detail. Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects. Link to comment
MBurleson Posted June 14 Author Share Posted June 14 It was specifically requested by the client...not sure why, but they insisted it opens a window like that and then redirects... Link to comment
creedon Posted June 15 Share Posted June 15 Quote It was specifically requested by the client...not sure why, but they insisted it opens a window like that and then redirects... Ah client demands. Understood. OK. I don't have an immediate solution but an observation. The reason the code works when the page first loads and the link is clicked is that LBA is loading that page up into the current page and your code to open the link runs. That happens once. The second click on the link does not load the LBA page but just shows it so the code to open the window does not run. A solution might be to not trigger off the page first load but some other event you can monitor. For example you might try tying into the click on the pay online link itself. Or, you could observe the show/hide state of the LBA itself. Again, I don't have any specific code, these are just ideas. Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects. Link to comment
MBurleson Posted June 21 Author Share Posted June 21 (edited) On 6/14/2023 at 7:04 PM, creedon said: Ah client demands. Understood. OK. I don't have an immediate solution but an observation. The reason the code works when the page first loads and the link is clicked is that LBA is loading that page up into the current page and your code to open the link runs. That happens once. The second click on the link does not load the LBA page but just shows it so the code to open the window does not run. A solution might be to not trigger off the page first load but some other event you can monitor. For example you might try tying into the click on the pay online link itself. Or, you could observe the show/hide state of the LBA itself. Again, I don't have any specific code, these are just ideas. How would you go about tying the event to the link click instead? Some Javascript in the footer injection that listens for that link to be clicked and then executes? I have tried this code: <script> function openLink(url) { window.open(url); } document.getElementByTagName("a[href='#1-pay-online']").addEventListener("click", function() { openLink("#lightbox_pay-online"); }); </script> While leaving the redirect JS on the pop-up page - doesn't seem to be working...maybe I have the code wrong or in the wrong spots...idk...getting past my coding knowledge now. Edited June 21 by MBurleson Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment