<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<span></span>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
<script>
$(document).ready(function () {
var url = 'http://iwjw.com/codes/code-repository?id=12#top';
var a = $('<a>', { href: url});
var sResult = '<b>Protocol:</b> ' + a.prop('protocol') + '<br>' + '<b>Host name: </b>' + a.prop('hostname') + '<br>'
+ '<b>Path: </b>' + a.prop('pathname') + '<br>'
+ '<b>Query: </b>' + a.prop('search') + '<br>'
+ '<b>Hash: </b>' + a.prop('hash');
$('span').html(sResult);
});
</script>
</body>
</html>
js --- url解析
最新推荐文章于 2024-05-23 10:06:04 发布