复制代码代码如下:
<! 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">
ฟังก์ชั่น 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)
-
อื่น
-
ถ้า (new_pagetit)
-
return_title = the_pagetitle & split_chr & new_pagetit;
-
-
การแจ้งเตือน (return_title);
-
</script>
</head>
<body>
<ค่าอินพุต = "测试" type = "ปุ่ม" onclick = "JavaScript: get_pagetitle ('_', '=');" -
</body>
</html>