最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

jQuery mobile轉(zhuǎn)換url地址及獲取url中目錄部分的方法

 更新時(shí)間:2015年12月04日 15:02:34   投稿:goldensun  
這篇文章主要介紹了jQuery mobile轉(zhuǎn)換url地址及獲取url中目錄部分的方法,轉(zhuǎn)換url地址本文中介紹的是將相對(duì)url轉(zhuǎn)化為絕對(duì)url,需要的朋友可以參考下

path.makeUrlAbsolute() 把相對(duì)URL轉(zhuǎn)化為絕對(duì)URL

jQuery.mobile.path.makeUrlAbsolute( relUrl, absUrl )

把相對(duì)URL轉(zhuǎn)化為絕對(duì)URL的方法。這個(gè)函數(shù)返回一個(gè)字符串,絕對(duì)URL。

relUrl:相對(duì)網(wǎng)址。類型:字符串。

absUrl:絕對(duì)網(wǎng)址。類型:字符串。

<!doctype html>
<html lang="en">
<head>
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <title>jQuery.mobile.path.makeUrlAbsolute demo</title>
 <link rel="stylesheet" >
 <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">
  <p>The absoulte URL used is http://foo.com/a/b/c/test.html</p>
  <input type="button" value="file.html" id="button1" class="myButton" data-inline="true">
  <input type="button" value="../../foo/file.html" id="button2" class="myButton" data-inline="true">
  <input type="button" value="http://foo.com/bar/file.html" id="button3" class="myButton" data-inline="true">
  <input type="button" value="?a=1&b=2" id="button4" class="myButton" data-inline="true">
  <input type="button" value="#bar" id="button5" 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 absUrl = $.mobile.path.makeUrlAbsolute( $( this ).attr( "value" ), "http://foo.com/a/b/c/test.html" ); 
  $( "#myResult" ).html( absUrl );
 }) 
});
</script>
 
</body>
</html>

path.get() 確定URL中的目錄部分

jQuery.mobile.path.get( url )

url:只有一個(gè)參數(shù)。類型:字符串。

確定URL中的目錄部分的實(shí)用方法。如果URL沒(méi)有斜線,URL的一部分被認(rèn)為是一個(gè)文件。這個(gè)函數(shù)返回一個(gè)給定的URL目錄部分。

<!doctype html>
<html lang="en">
<head>
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <title>jQuery.mobile.path.get demo</title>
 <link rel="stylesheet" >
 <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="http://foo.com/a/" id="button2" class="myButton" data-inline="true" />
  <input type="button" value="http://foo.com/a" id="button3" class="myButton" data-inline="true" />
  <input type="button" value="http://foo.com/a/file.html" id="button4" class="myButton" data-inline="true" />
  <input type="button" value="/a/file.html" id="button5" class="myButton" data-inline="true" />
  <input type="button" value="file.html" id="button6" class="myButton" data-inline="true" />
  <input type="button" value="/file.html" id="button7" class="myButton" data-inline="true" />
  <input type="button" value="?a=1&b=2" id="button8" class="myButton" data-inline="true" />
  <input type="button" value="#foo" id="button9" 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 dirName = $.mobile.path.get( $( this ).attr( "value" ) ); 
  $( "#myResult" ).html( String( dirName ) );
 }) 
});
</script>
 
</body>
</html>

相關(guān)文章

最新評(píng)論

高雄县| 东海县| 山丹县| 冕宁县| 安宁市| 汉阴县| 逊克县| 宣恩县| 化德县| 江口县| 辽阳县| 虞城县| 宣威市| 呼伦贝尔市| 利津县| 抚松县| 广丰县| 揭西县| 嘉义市| 富川| 肃北| 赤峰市| 泰州市| 凌源市| 正定县| 密云县| 突泉县| 绥德县| 望城县| 苍南县| 清徐县| 什邡市| 阳城县| 米林县| 梅州市| 常州市| 稷山县| 资阳市| 建阳市| 礼泉县| 洪泽县|