What about hyperlinks (2): Attributes href and those href
One of the attributes of tag a, href
1. Definition
The href attribute is used to specify the URL of the hyperlink target.
2. Usage
①. Anchor
- Add an anchor on the same page
(1) <a href = "# test"> connection to the anchor of the current page </a> // click
(2) <a name = "test"> anchor </a> // place it in the content to jump
- Add an anchor across pages
(1)create an anchor in test2.html <a name = "test"> anchor </a>
(2)set the connection in test1.html <a href = "test2.html # test"> the hyperlink to the anchor of another page </a>
②. Download
<a href="download.rar"></a>
The url in href must be valid, preferably in rar format.
3. Call
<A href = "tel: Phone Number"> </a>
④. Email
Email Tag:Mailto
Nature:Cc:CC
Bcc: Dark copy
Subject:Topic
Body:Email content
<A href = "mailto: xxx@xx.com"> </a>
- Use commas (,) to send multiple addresses
<A href = "mailto: xxx@xx.com, xxx@xx.com"> </a>
<A href = "mailto: xxx@xx.com? Cc = xxx@xx.com & bcc = xxx@xx.com & subject = subject & body = content "> </a>
⑤. Javascript
<A href = "javascript: function_name ()"> </a>
The W3C standard does not recommend executing javascript statements in href. this method is prone to problems when passing this and other parameters, and javascript: when the protocol is used as the href attribute of a, not only does it cause unnecessary window triggering. the onbeforeunload event stops playing GIF animated images in IE.
- Use void,:, undefined, with onclick
<A href = "javascript:" onclick = "function_name ()"> </a>
<A href = "javascript: void (0)" onclick = "function_name ()"> </a>
<A href = "javascript: undefined" onclick = "function_name ()"> </a>
The most common method is also the most comprehensive method. The Js method is not exposed in the address bar because the address does not jump.
<A href = "#" onclick = "function_name ()"> </a>
'#' Is a built-in label method, which represents the role of top, so after executing the method, return to the top of the page.
<A href = "#" onclick = "function_name (); return false;"> </a>
After 'Return false' is executed, the page does not jump, and the page stays at the current position.
To be continued ....