如何改变源iframe,然后重新加载,但一个命令,而不是一个链接


How to change source of iframe and then reload, but a command instead of a link

我有这个代码

if(stripos($text," on")!==FALSE){
//here it should goto 192.168.1.102/?dev=light?cmd=on
}
else{
//here it should goto 192.168.1.102/?dev=light?cmd=off
}

,我希望它在iframe中打开地址,但不是使用超链接来更改iframe的源,而是使用命令,这将立即完成…你们能帮帮我吗?:)维克多

当你使用PHP在服务器端运行代码时,你制作了一个完整的HTML页面(标签,iframes &),浏览器将刷新。您可以在PHP代码中设置iframe的新源代码。如果你想在不完全刷新的情况下改变帧源,你可以在客户端使用javascript:

<SCRIPT LANGUAGE="JavaScript">
    document.getElementById('myframe').src = '192.168.1.102/?dev=light?cmd=on';
</script>