I have a strange setup that requires an iframe which then has a link to open a new tab/window.
When someone clicks on the link I need the link open in the new tab and the parent page to reload. The reason for this is that when the page reloads it changes the message to a completed message so that when the user finishes using the new window page it closes and defaults back to this complete message.
I’ve tried a few things and am pretty close to getting it to work but just can’t get the last bit
I’m using this (not my original code)
//Open in new tab
//focus to that window
//Reload the parent window
This is not currently working as it will open the link but not reload the page but if I change the ‘reload’ part to being first in the list it does reload the page but then doesn’t open the tab.
Any thoughts how to get it to achieve both?
Hi @Noppy, with just
it would actually open a new tab, switch to that new tab, and immediately reload the original window (tested in chrome and FF). It’s the
focus() part that’s not working for me… is that what you actually want to do, switch back to the the original window right after opening the new tab? Otherwise it would be
const child = window.open(url, '_blank')
… but again that would be the default behaviour anyway.
It was a bit of a weird situation so I’m not sure if it is wix that is preventing it reloading as I think wix loads iframes in a strange way.
If I try the embedded page directly it will open the new tab and reload the page correctly. It just won’t do it in an iframe from a wix page.
I’ve done a work around though that I think will work for us, instead of trying to reload the page and using PHP (hence the reload) I simply used some JS to inject some html onto the page when the link is clicked before it opens the new tab. It seems to do the job.
I’ll have a play with the code you mention out of interest and see if that will work how I was initially thinking.
Ah okay, thanks for the clarification! Using JS to update the content seems like a more elegant solution anyway IYAM…