複製代碼代碼如下:
<!Doctype HTML公共“ - // W3C // DTD XHTML 1.0 Transitional // en”“” http://www.org/tr/tr/xhtml1/dtd/xhtml1-xhtml1-transitional.transitional.dtdd'>
<html xmlns =“ http://www.w3.org/1999/xhtml”>
<頭>
<meta http-equiv =“ content-type” content =“ text /html; charset = gb2312” />
<title> javascript_ </title>
<腳本語言=“ javascript”>
函數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)
}
別的
{
if(new_pagetit)
{
return_title = the_pagetitle&split_chr&new_pagetit;
}
}
警報(return_title);
}
</script>
</head>
<身體>
<input value =“測試” type =“ button” onclick =“ javascript:get_pagetitle('_ _','=');” />
</body>
</html>