Usage of the Target attribute of Hyperlink

Source: Internet
Author: User
Let's take a look at Asp.net's ASP. NET articles -- Updated daily! Click the link to open an article in a new window. Article Do not close the new window and click the link of another article. You can find that the new link does not open a new window, but loads it in the previously opened window, in this way, we can avoid opening too many new windows.
Curious. Read it. Source code , Nothing special, but I checked msdn and found that the target attribute is explained as follows:

Possible values

Starget String That specifies or distinct es one of the following values.

Name The name of the target window or frame.
_ Blank Load the linked document into a new blank window. This window is not named.
_ Media Load the linked document into the HTML content area of the media bar. Available in Internet Explorer 6 or later.
_ Parent Load the linked document into the immediate parent of the document the link is in.
_ Search Load the linked document into the browser search pane. Available in Internet Explorer 5 or later.
_ Self Default. Load the linked document into the window in which the link was clicked (the active window ).
_ Top Load the linked document into the topmost window.

The property is read/write. The property has a default value_ Self.

Let's see why I marked it in red. Hyperlink in Asp.net's article list sets this attribute target = "_ new ".

Try the followingCodeAnd I made the same effect.
Aspnetupload.net
Upload4asp.net

But it is a little bad. After I open a new page, I return to the home page and click another link. Although the new link has been loaded, it does not automatically get the focus, but stays on the home page. A solution is to add JavaScript code to the new page:

< Script Language = Javascript >

Script>

Obtain or set the URL to be linked when you click the hyperlink control.

Namespace: System. Web. UI. webcontrols

ProgramSet: System. Web (in system. Web. dll)

Attribute Value
Click the URL to which the hyperlink control is linked. The default value is an empty string ("").

Example

<% @ Page Language = "C #" autoeventwireup = "true" %>
<HTML>
<Head>

</Head>
<Body>

<H3> hyperlink example

Click on the hyperlink: <br>

<Asp: hyperlink id = "hyperlink1"
Imageurl = "images/pict.jpg"
Navigateurl = "http://www.microsoft.com"
TEXT = "Microsoft official site"
Target = "_ new"
Runat = "server"/>

</Body>
</Html>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.