Adding "target" Attribute To All Links

C

Chris Marsh

All

We have a requirement to add a "target" attribute with a value of "_parent"
to any links in a given .aspx page, UNLESS a target has already been
specified for that link. We are not in control of content, the page in
question is referenced from an iframe, and we need any links from this page
to open in the browser window rather than the iframe. We already have a
Response filter in operation which replaces a token with a specified URL (a
logically separate task to this new task) - would it be a good idea to put
this additional functionality in the same Response filter class?

Would a regular expressiojn replace operation be a good idea, and if so
could anyone point me in the right direction of how to do this? I have
created the regexp for an anchor tag with no trouble, but I'm not sure how
to *not* match any anchor tags that already have a target attribute. I'm
also a bit shady on how to replace a string with a mutated version of that
string.

Anyway, in the meanwhile I'll RTM, but if anyone has any information or
advice I would very much appreciate it.

Cheers!
 
C

Chris Marsh

All

Chris Marsh said:
We have a requirement to add a "target" attribute with a value of
"_parent" to any links in a given .aspx page, UNLESS a target has already
been specified for that link. We are not in control of content, the page
in

The following tag in the <head> section of the page does just what I need
<base target="_parent"> .

[..]

Cheers!
 
D

Duy Lam

Chris said:
All

Chris Marsh said:
We have a requirement to add a "target" attribute with a value of
"_parent" to any links in a given .aspx page, UNLESS a target has already
been specified for that link. We are not in control of content, the page
in

The following tag in the <head> section of the page does just what I need
<base target="_parent"> .

[..]

Cheers!

If you have used Theme, just insert HyperLink control to it
<asp:HyperLink runat="server" target=_parent">

Anyway, it's alternative option for you :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top