读书人

怎么根据不同的判断条件引入不同的htm

发布时间: 2012-02-28 13:06:35 作者: rapoo

如何根据不同的判断条件引入不同的html文件
我想根据不同的条件引入不同的文件,类似这种效果:
if( flag == true )
{
<!--#include file= 'a.html '-->
}
else
{
<!--#include file= 'b.html '-->
}
但这样肯定是不行的,服务器端解析都引入了。请问仅靠javascript实现这个效果方法吗?

[解决办法]
用iframe试试
[解决办法]
仅仅依靠javascript不能实现这个效果的。你不是用php做吗?
[解决办法]
<iframe id= 'content ' src= 'xxx.htm '> </iframe>
<input type= 'button ' onclick= 'chagehtm() ' value= '改变页面 '/>

<script type= 'text/javascript '>
function chagehtm()
{
if( flag == true )
{
content.src= 'a.html ';}
else
{
content.src= 'b.html ';
}

}
</script>

读书人网 >JavaScript

热点推荐