Open link inside iframe in new windows

I have an MVC application that reads some data from a database and loads that data into an iFrame (to understand that you are reading your letters in the application).

The problem is that the content of the HTML message has several hyperlinks (I cannot know exactly how many hyperlinks are in the message, I only read it and convert it to HTML for display in the application), and the user wants the application to open each hyperlink on a new page windows, because if the hyperlink does not have a target = "_ blank", it opens on the iframe itself; so I'm wondering if there is a way to make all the hyperlinks inside the iframe open in a new window. The only code I have is (for example):

<iframe src="/PruebaMVC/Home/VerHTML/?q=Pgaw9XpWBuvzSNaGe13Efg==&f=9795246-9_633988839808733263" style="padding: 0 0 0 0;margin:0 0 0 0" height="100%" width="100%" frameborder="0"></iframe>

Therefore, I cannot change every hyperlink inside the message to refer to target = "_ blank", I am looking for a universal solution. I appreciate any help. Thanks in advance.

+3
source share
1 answer

If you can manage the content <iframe>, a simple solution is to insert a tag <base>:

<base target="_blank" />
+6
source

Source: https://habr.com/ru/post/1728172/


All Articles