首页 > 技术文章 > 超链接的各种功能

LO-gin 2016-04-05 14:07 原文

超链接的各种功能:

     <!DOCTYPE html>  
    <html>  
    <head>  
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
    <title>超链接的各种功能</title>  
    <meta name="viewport" content="width=device-width, initial-scale=1.0">  
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css">  
    <script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>  
    <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>  
    </head>  
    <body>  
    <div data-role="page">  
      <div data-role="header" data-position="fixed">  
        <h1>超链接的各种功能</h1>  
      </div>        
      <div data-role="content">  
        <p><a href="sms:10086?body=短信内容" data-role="button" data-theme="a">测试发短信(移动端)</a></p>  
        <p><a href="tel:10086" data-role="button" data-theme="a">测试打电话(移动端)</a></p>  
        <p><a href="mailto:test@163.com" data-role="button" data-theme="a">测试发邮件</a></p>  
        <p><a href="weixin://" data-role="button" data-theme="a">打开微信(移动端)</a></p><!-- 使用RUL scheme 打开app -->
        <p><a href="weixin://dl/moments" data-role="button" data-theme="a">打开微信朋友圈(移动端)</a></p><!-- 使用RUL scheme 打开app -->
        <p><a href="test.txt" data-role="button" data-theme="a">读取文件</a></p> 
        <p><a href="javascript:void(0);" data-role="button" data-theme="a">调用js</a></p> 
        <p><a href="javascript:alert('这是弹窗内容')" target="_blank" data-role="button" data-theme="a">弹窗</a></p> 
        <p><a href="#test" data-role="button" data-theme="a">锚点链接</a></p> 
        <p><a href="http://www.baidu.com" data-role="button" data-theme="a">跳转到一个网页</a></p> 
        <p><a href="#" data-role="button" data-theme="a">空链接</a></p> 
      </div>  
      <div data-role="footer" data-position="fixed">  
        <h1>超链接的各种功能</h1>  
      </div>  
    </div>  
    </body>  
    </html>  

 

超链接跳转到不同页面的锚点链接:

在做前端的时候,有时会遇到这样一种情况:要在此页面跳转到另一个页面的某个地方。这种情况,就可以使用超链接和锚点链接进行调转了。比如要从index.html页面的某个超链接调转到single.html页面的底部,则此时可在single.html页面底部添加一个锚点。然后在index.html的超链接里加上此锚点的名称即可。

 

index.html页面的超链接:

<a href="single.html#CompanyProfile">企业概况</a>

 

single.html页面的锚点:

<h2><a name="CompanyProfile">企业概况</a></h2>

 

这样,在index.html页面点击了超链接后就直接跳转到single.html页面“企业概况”标题了。

推荐阅读