Adding "target" Attribute To All Links

Discussion in 'ASP .Net' started by Chris Marsh, Dec 11, 2007.

  1. Chris Marsh

    Chris Marsh Guest

    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!

    --
    Chris Marsh
     
    Chris Marsh, Dec 11, 2007
    #1
    1. Advertising

  2. Chris Marsh

    Chris Marsh Guest

    Re: Adding "target" Attribute To All Links [SOLVED]

    All

    "Chris Marsh" <> wrote in message
    news:%23q$mW5%...
    > 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!

    --
    Regards

    Chris Marsh
     
    Chris Marsh, Dec 11, 2007
    #2
    1. Advertising

  3. Chris Marsh

    Duy Lam Guest

    Re: Adding "target" Attribute To All Links [SOLVED]

    Chris Marsh wrote:
    > All
    >
    > "Chris Marsh" <> wrote in message
    > news:%23q$mW5%...
    >> 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 :)

    --
    Duy Lam Phuong
     
    Duy Lam, Dec 11, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DaMoe
    Replies:
    6
    Views:
    21,218
    praveenbattula
    Jun 26, 2010
  2. data64

    Re: Links and target

    data64, Apr 3, 2004, in forum: HTML
    Replies:
    2
    Views:
    389
    Rob McAninch
    Apr 3, 2004
  3. Ken Fine
    Replies:
    2
    Views:
    13,165
    Ken Fine
    Sep 25, 2006
  4. mohit
    Replies:
    0
    Views:
    603
    mohit
    Jan 23, 2008
  5. Gerald Shastri

    Using Javascript to add target attribute to links

    Gerald Shastri, Feb 19, 2007, in forum: Javascript
    Replies:
    0
    Views:
    112
    Gerald Shastri
    Feb 19, 2007
Loading...

Share This Page