日期:2014-05-16  浏览次数:20316 次

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