您现在的位置是:首页 > 电脑技术查询 > web开发

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

编辑:chaxungu时间:2022-10-02 23:18:11分类:web开发

如何根据不同的判断条件引入不同的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>