[html]
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$(".btn").click(function(){
var p4 = $(".text").val();
var rule2 = /(\w+):\/\/(\w+\.?\w+\.\w+)(:?\d*)(\/(\w|\W)+)/;
var re2 = p4.replace(rule2,"");
var xy = RegExp.$1;
var dz = RegExp.$2;
var hz = RegExp.$4;
$("span").append("協議是:"+xy+"<br />網址是:"+dz+"<br />尾碼是:"+hz);
});
});
</script>
<style type="text/css">
div { width:400px; padding:10px; border:1px solid #000; margin:200px auto;}
.text { width:400px; height:300px; resize:none;}
.btn { width:100px; height:20px; margin:20px 0 0;}
</style>
<title>網址截取</title>
</head>
<body>
<div>
<textarea class="text">http://www.ifblooms.com/thread-4479-1-1.html</textarea>
<p>輸入網址,分解為協議、網域名稱地址以及頁面路徑</p>
<input class="btn" value="擷取" type="button" /><br />
<span></span>
</div>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$(".btn").click(function(){
var p4 = $(".text").val();
var rule2 = /(\w+):\/\/(\w+\.?\w+\.\w+)(:?\d*)(\/(\w|\W)+)/;
var re2 = p4.replace(rule2,"");
var xy = RegExp.$1;
var dz = RegExp.$2;
var hz = RegExp.$4;
$("span").append("協議是:"+xy+"<br />網址是:"+dz+"<br />尾碼是:"+hz);
});
});
</script>
<style type="text/css">
div { width:400px; padding:10px; border:1px solid #000; margin:200px auto;}
.text { width:400px; height:300px; resize:none;}
.btn { width:100px; height:20px; margin:20px 0 0;}
</style>
<title>網址截取</title>
</head>
<body>
<div>
<textarea class="text">http://www.ifblooms.com/thread-4479-1-1.html</textarea>
<p>輸入網址,分解為協議、網域名稱地址以及頁面路徑</p>
<input class="btn" value="擷取" type="button" /><br />
<span></span>
</div>
</body>
</html>