Adding "target" Attribute To All Links

  • Thread starter Thread starter Chris Marsh
  • Start date Start date
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!
 
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!
 
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 :-)
 
Back
Top