2

Good day,

I was trying to open a new tab in Safari IOS 13.3 using javascript (mobile), but no luck.

I'am trying this: a href="#" onClick="window.open(url, '_blank')", however, it is not working on SAFARI, but working in Chrome.

Need some help. Thanks

user3928201
  • 125
  • 1
  • 2
  • 8
  • Possibly it cannot be done? They have their own behaior on what *backs* mean. Can you elaborate why you need a new tab? – GetSet Feb 04 '20 at 01:02
  • the link on the "a" tag opens up a pdf supposedly, then the safari would open the pdf but in the same page, i need this in the new tab. I need this in the new tab because when it opens in the same page and click the "back" button, the whole page refreshes. – user3928201 Feb 04 '20 at 01:06
  • Do you need this behavior on iphones and i/devices? If they do not support it then whats your grief? If You really want someone to see a pdf before the phone or device takes over, have you looked at the `iframe` tag? You can load the .pdf in the iframe and ios has no choice. – GetSet Feb 04 '20 at 01:07
  • Can't do opening it in iframe, since it is a downloable link (supposedly) – user3928201 Feb 04 '20 at 09:27
  • Most browsers (dont know bout ios) will still have a button to download the pdf in the rendered view within an iframe. But if you want the pdf to download without ever opening, then thats kinda different from your original question but totally doable with the appropriate headers. – GetSet Feb 04 '20 at 10:49

1 Answers1

0

You can use attribute target=_blank in anchor tags. https://www.w3schools.com/tags/att_a_target.asp

For example:

<a href="https://www.google.com" target="_blank">Click here to open Google</a>
Loc Mai
  • 217
  • 3
  • 9