戻る

URLを短縮する

chapter90.html

<!DOCTYPE HTML>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
<script type="text/javascript">
 
$("#index").live('pagecreate',function(){

	$(":button").live("tap",function(){
	
		$("#show").html("");
		
		var url = $(":text").val()
		 
		var con = $.getJSON("https://api-ssl.bitly.com/v3/shorten?login=o_pt924l72s&apiKey=R_2d00d2bbe6cc7850d6d65f7c1277c3ce&longUrl=" + url + "&format=json&callback=?",
		function(data){
		
			console.log(data);
			
			$("<a>").attr("href",data.data.url).text(data.data.url).appendTo("#show");
			
		});
		con = null;
	});
	
});
</script>
<title></title>
</head>
<body>
<div data-role="page" id="index">
	<div data-role="header">
		<h1>bit.lyでURL短縮</h1>
	</div>
	<div data-role="content">
		<input type="text" value="http://" />
		<input type="button" value="短縮" />
		<p id="show">
		</p>
	</div>
	<div data-role="footer">
		<h4>Yohsuke Nakano</h4>
	</div>
</div>
</body>
</html>

inserted by FC2 system