加入收藏 | 设为首页 | 会员中心 | 我要投稿 聊城站长网 (https://www.0635zz.com/)- 智能语音交互、行业智能、AI应用、云计算、5G!
当前位置: 首页 > 教程 > 正文

javascript 获取网页标题代码示例

发布时间:2023-09-26 14:56:19 所属栏目:教程 来源:
导读:代码如下:

<!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>

<
代码如下:
 
<!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>
 
<script language="javascript">
 
function 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)
 
 }
 
 else
 
 {
 
  if(new_pagetit)
 
  {
 
   return_title=the_pagetitle & split_chr & new_pagetit;
 
  }
 
 }
 
 alert(return_title);
 
}
 
</script>
 
</head>
 
<body>
 
<input value="测试"  type="button" onclick="javascript:get_pagetitle('_','=');" />
 
</body>
 
</html>
 
 

(编辑:聊城站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章