Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
438 views
in Technique[技术] by (71.8m points)

javascript - How to open in a new tab a link clicked in a PDF document that is in an iframe?

I use iframe to display PDF file in my Angular website like this <iframe src='./assets/privacy_policy.pdf'></iframe> however if the user clicks on the links contained in the document they are opened in the iframe. Does anyone have any idea how to make them open in a new window or tab? Probably I need something working like target="_blank".

question from:https://stackoverflow.com/questions/65850414/how-to-open-in-a-new-tab-a-link-clicked-in-a-pdf-document-that-is-in-an-iframe

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

use this code :

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <base href="https://www.w3docs.com/" target="_blank">
  </head>
  <body>
    <iframe src="https://www.w3docs.com" width="500" height="500"></iframe>
  </body>
</html>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...