免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3144 | 回复: 3
打印 上一主题 下一主题

[TITLE] 用document.getElementById方法,在另外shtml页面显示变量的问题,请教高手。 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-06-14 09:38 |只看该作者 |倒序浏览
问题是这样的,为了提高网站显示速度,所以用生成静态页面,再用shtml去include生成的静态页面。
但是在shtml页面中,document.getElementById在<body>中可以显示事先定义的变量,在<title>中则不能,求解决办法,谢谢。以下是相关代码。
-------test.php--------

$a = $xpath->query("/Article/oraDate/RKLSWZBT");
$newszbt = iconv("UTF-8","GB2312",$a->item(0)->nodeValue);

$newspos =        unhtmlentities(iconv("UTF-8","GB2312",$a->item(0)->nodeValue));
$newspos =        str_replace("$",">>",substr($newspos,1));

document.getElementById('contPostion').innerHTML="当前位置:<?echo $newspos?>正文"
document.getElementById('conttitle').innerHTML="详细-<?echo $newszbt?> "

定义了2个变量,'contPostion'是页面的导航条,'conttitle'是页面的标题。

----------test.shtml------

<div id="contPostion" style="margin-top:12px;margin-left:10px;" align="left">当前位置:</div>      ----当前位置可以正常显示导航条

<title><div id="conttitle" style="margin-top:12px;margin-left:10px"; align="left">详细-</div></title>     ----title不能正常显示。

求助各位高手,谢谢。

[ 本帖最后由 HonestQiao 于 2006-6-14 10:43 编辑 ]

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
2 [报告]
发表于 2006-06-14 10:45 |只看该作者
这个你要看在浏览器里面的显示的html的源代码是什么啊。

论坛徽章:
0
3 [报告]
发表于 2006-06-14 11:31 |只看该作者
导航条用的是<div id="contPostion" style="margin-top:12px;margin-left:10px;" align="left">当前位置:</div>
其中的id="contPostion"和document.getElementById('contPostion').innerHTML="当前位置:<?echo $newspos?>正文"  相对应。
大段html如下:
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" id="header_nav">
  <tr>
    <td><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
      <tr>
        <td width="74%" valign="middle" class="font_black_12px"><div id="contPostion" style="margin-top:12px;margin-left:10px;" align="left">当前位置:</div></td>
      </tr>
    </table></td>
    <td id="header_nav_right"><img src="images/1_1-31-479_20031021165910.gif" width="100" height="28" /></td>
  </tr>
</table>  
以上是显示导航条的,想在<title></title>里面显示文章标题啊,555,一上午了没搞定。
<title><div id=XXX></title>和<title id=XXX></title>均无效,郁闷。
乔老大再帮忙指点几句啊,谢谢。。。

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
4 [报告]
发表于 2006-06-14 15:47 |只看该作者
title里面不能这么做的。

需要使用:doucment.title="..."
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP