javascript 获取网页标题代码实例
更新时间:2014年01月22日 16:29:42 作者:
这篇文章主要介绍了javascript 获取网页标题代码实例,有需要的朋友可以参考一下
复制代码 代码如下:
<!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>
相关文章
JS使用对象的defineProperty进行变量监控操作示例
这篇文章主要介绍了JS使用对象的defineProperty进行变量监控操作,结合实例形式分析了对象defineProperty方法的功能及简单使用技巧,需要的朋友可以参考下2019-02-02


最新评论