javascript 获取网页标题的代码
发布时间:2015-05-01 编辑:jiaochengji.com
分享一例javascript实现的获取网页标题的代码,有需要的朋友可以做个参考。
本节内容:
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_获取网页标题代码_www.jiaochengji.com</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>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>javascript_获取网页标题代码_www.jiaochengji.com</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获取网页标题示例代码
javascript 获取网页标题的代码
ExtJS获取网页标题示例代码
PHP 获取网页源代码、网页标题的实现代码
JS读取与修改网页标题
如何使用母版页来实现统一格式的网页标题
JavaScript加入收藏夹(自动获取网址与标题)
js获取浏览器窗口大小与屏幕宽高
php获取远程网址的html代码
Javascript获得当前网页详细地址的代码
上一篇:禁止拷贝复制网页内容的js代码
下一篇:js div拖拽实现代码
[关闭]