复制代码代码如下:
<!doctype html public " - // w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<Meta http-equiv = "content-type" content = "text /html; charset = gb2312" />
<title>javascript_获取网页标题代码</title>
<スクリプト言語= "javascript">
function get_pagetitle(split_chr、new_pagetit)
{
var tittitiTems、return_title;
var the_pagetitle = document.title;
pittiteItems = the_pagetitle.split(split_chr);
return_title = the_pageTitle;
if(titleItems [1])
{
return_title = the_pageTitle.Replace(titleItems [1]、new_pagetit)
}
それ以外
{
if(new_pagetit)
{
return_title = the_pageTitle&split_chr&new_pagetit;
}
}
alert(return_title);
}
</script>
</head>
<body>
<入力値= "测试" type = "button" onclick = "javascript:get_pageTitle( '_'、 '=');" />
</body>
</html>