lidermin
lidermin

Reputation: 2832

open link inside iframe in new windows

I have a MVC application that reads some data from a database and loads that data into an iFrame (to get the feeling that you're reading your emails on the application).

The issue is that the content of the HTML message has several hyperlinks (I can't certainly know how many hyperlinks are there on the message, I only read it and convert it to HTML to display on the application) and the user wants the application to open each hyperlink on a new window page, because if the hyperlink doesn't have the target="_blank" it opens up on the iframe itself; so I'm wondering if there's any way to force all the hyperlinks inside the iframe to open on a new window. The only code i have is this (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>

So I can't change each hyperlink inside the message to reference to target="_blank", I'm looking for a generic solution. I appreciate any help. Thanks in advance.

Upvotes: 3

Views: 7588

Answers (1)

Kobi
Kobi

Reputation: 137997

If you can control the content of the <iframe>, an easy solution is to insert a <base> tag:

<base target="_blank" />

Upvotes: 6

Related Questions