html 从URL重新标题HTML

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html 从URL重新标题HTML相关的知识,希望对你有一定的参考价值。

<html>

<head>
</head>

<body onload="setTitle()">

<script type="text/javascript">
function setTitle(){
	var pageUrl = window.location;
	var pageString = String(pageUrl);
	// adjust text before and after section of URL to isolate
	// example - http://mysite.com/somejunk/HERE/morejunk.html
	// regEx to receive new title of "HERE" would be: /.+somejunk\/(.+)\/morejunk.+/
	var regEx = /.+textbefore(.+)textafter.+/;
	var newTitle = pageString.match(regEx);
	window.document.title = newTitle[1];
}
</script>

</body>
</html>

以上是关于html 从URL重新标题HTML的主要内容,如果未能解决你的问题,请参考以下文章