麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 語言 > JavaScript > 正文

使用jQuery mobile庫檢測url絕對地址和相對地址的方法

2024-05-06 16:25:50
字體:
來源:轉載
供稿:網友
這篇文章主要介紹了使用jQuery mobile庫監測絕對地址和相對地址的方法,分別是isAbsoluteUrl()和isRelativeUrl()方法的使用,需要的朋友可以參考下
 

path.isAbsoluteUrl() 檢測絕對網址

jQuery.mobile.path.isAbsoluteUrl(url)

如果一個URL是絕對的實用方法。如果URL是絕對的這個函數返回一個布爾值 true ,否則返回 false。

<!doctype html><html lang="en"><head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>jQuery.mobile.path.isAbsoluteUrl demo</title> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css"> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <!-- The script below can be omitted --> <script src="/resources/turnOffPushState.js"></script> <script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script> <style> #myResult{ border: 1px solid; border-color: #108040; padding: 10px; } </style></head><body> <div data-role="page">  <div data-role="content"> <input type="button" value="http://foo.com/a/file.html" id="button1" class="myButton" data-inline="true" /> <input type="button" value="//foo.com/a/file.html" id="button2" class="myButton" data-inline="true" /> <input type="button" value="/a/file.html" id="button3" class="myButton" data-inline="true" /> <input type="button" value="file.html" id="button4" class="myButton" data-inline="true" /> <input type="button" value="?a=1&b=2" id="button5" class="myButton" data-inline="true" /> <input type="button" value="#foo" id="button6" class="myButton" data-inline="true" /> <div id="myResult">The result will be displayed here</div> </div></div><script>$(document).ready(function() {  $( ".myButton" ).on( "click", function() {   var isAbs = $.mobile.path.isAbsoluteUrl( $( this ).attr( "value" ) );  $( "#myResult" ).html( String( isAbs ) ); }) });</script> </body></html>

 

path.isRelativeUrl() 檢查相對網址

jQuery.mobile.path.isRelativeUrl( url )

如果URL是相對的網址,這個函數返回一個布爾值 true,否則返回 false。

<!doctype html><html lang="en"><head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>jQuery.mobile.path.isRelativeUrl demo</title> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css"> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <!-- The script below can be omitted --> <script src="/resources/turnOffPushState.js"></script> <script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script> <style> #myResult{ border: 1px solid; border-color: #108040; padding: 10px; } </style></head><body> <div data-role="page">  <div data-role="content"> <input type="button" value="http://foo.com/a/file.html" id="button1" class="myButton" data-inline="true" /> <input type="button" value="//foo.com/a/file.html" id="button2" class="myButton" data-inline="true" /> <input type="button" value="/a/file.html" id="button3" class="myButton" data-inline="true" /> <input type="button" value="file.html" id="button4" class="myButton" data-inline="true" /> <input type="button" value="?a=1&b=2" id="button5" class="myButton" data-inline="true" /> <input type="button" value="#foo" id="button6" class="myButton" data-inline="true" /> <div id="myResult">The result will be displayed here</div> </div></div><script>$(document).ready(function() {  $( ".myButton" ).on( "click", function() {   var isRel = $.mobile.path.isRelativeUrl( $( this ).attr( "value" ) );  $( "#myResult" ).html( String( isRel ) ); }) });</script> </body></html>


注:相關教程知識閱讀請移步到JavaScript/Ajax教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 91九色论坛 | 毛片视频免费观看 | 视频一区二区中文字幕 | 亚洲一区久久 | 国产精品久久久久久久久久久久久久久久 | 91看片免费版 | 亚洲国产美女视频 | 吾色视频 | 青青青在线免费 | 午夜在线视频一区二区三区 | 麻豆一二区 | 国产黄色一区二区 | 91成人免费看片 | 久久精品亚洲国产奇米99 | 亚洲视频综合 | 国产一国产一级毛片视频在线 | 一级黄色影院 | 草草视频免费 | 国产精品视频久久久 | 国产精品爆操 | 草b视频在线观看 | 国产午夜精品一区二区三区免费 | 亚洲一区二区在线 | 一级国产免费 | 一级尻逼视频 | 久久av一区二区 | 男人久久天堂 | 日本中文视频 | xvideos korean| 91九色福利| 国产一级二级视频 | 自拍偷拍亚洲图片 | 毛片免费看电影 | 日韩视频在线免费 | 激情网站免费观看 | 精品一区二区三区日本 | 久久福利在线 | 黄色的视频免费观看 | 182tv成人福利视频免费看 | fc2国产成人免费视频 | 午夜视频久久 |