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>