复制代码代码如下:
<! DocType html public "-// w3c // dtd xhtml 1.0 Transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transicional.dtd ">
<html xmlns = "http://www.w3.org/1999/xhtml">
<Evista>
<meta http-equiv = "content-type" content = "text /html; charset = gb2312" />
<title> javascript_ 获取网页标题代码 </title>
<script language = "javaScript">
función get_pagetitle (split_chr, new_pagetit)
{
VAR TitleItems, return_title;
var the_pageTitle = document.title;
titleItems = the_pagetitle.split (split_chr);
return_title = the_pagetitle;
if (titleItems [1])
{
return_title = the_pagetitle.replace (titleItems [1], new_pagetit)
}
demás
{
if (new_pagetit)
{
return_title = the_pagetitle & split_chr & new_pagetit;
}
}
alerta (return_title);
}
</script>
</ablo>
<Body>
<input value = "测试" type = "button" onClick = "javascript: get_pageTitle ('_', '=');" />
</body>
</html>