0

I have following code in my Next.js function. I want the url to be opened in the same tab but in a new smaller window.

window.open(url, '_blank', features)

where features are,

const features = `width=${newWindowWidth}, height=${newWindowHeight}, top=${top}, left=${left}`;

This works well on mac when in minimised browser mode (same on Firefox, safari, chrome). but as you switch to maximised browser mode. it suddenly opens the url in new tab. How to persist the behaviour of opening in a small new window in the same tab?

I know it's a duplicate here. but no solution/answers are there. Thus, asking it again.

1 Answer 1

0

You could use an iframe and:

  • set the webplace to be displayed as the value of src
  • set the width to be the value of width
  • set the height to be the value of height
  • make sure that the widget site allows to be displayed inside an iframe of your main site if they are of different domains
  • adjust CSP if necessary
  • as for top, you can set the position to the one you desire (see https://developer.mozilla.org/en-US/docs/Web/CSS/top) and set a CSS style property to the value you want
2
  • Hey. Thanks it works for other URL but the url i have is the stripe payment link which has security restrictions and can't be opened in an iframe. Commented May 11 at 17:18
  • @NidhiDadiya then you can create an end point in your site and that end point would be essentially a proxy to stripe, so the browser would not restrict you. This should work with your end point doing the posting to stripe as long as stripe does not have further restrictions. Commented May 11 at 19:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.