1. js如何写html页面
js输出html中表格的方法如下:
document.write("<table border=1 >")
for(i=1;i<=r;i++)
{
document.write("<tr>")
for(j=1;j<=c;j++)
document.write("<td>"+Math.pow(j,i)) //输出数组
document.write("</tr>")
}
document.write("</table>")
运行结果:
2. Thinkphp后台如何用js跳转到指定页面 怎么写
要实现从一个页面A跳到另一个页面B,js实现就在A的js代码加跳转代码
JS跳转大概有以下几种方式:
第一种:(跳转到b.html)
<script language="javascript" type="text/javascript">
window.location.href="b.html";
</script>
第二种:(返回上一页面)
<script language="javascript">
window.history.back(-1);
</script>
第三种:
<script language="javascript">
window.navigate("b.html");
</script>
第四种:
<script language="JavaScript">
self.location='b.html';
</script>
第五种:
<script language="javascript">
top.location='b.html';
</script>
3. 我要js调用整个页面,应该怎样写JS
function createXMLHttpRequest(){ if(window.XMLHttpRequest){ XMLHttpR = new XMLHttpRequest(); }else if(window.ActiveXObject){ try{ XMLHttpR = new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){ try{ XMLHttpR = new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){ } } } } function sendRequest(url){ createXMLHttpRequest(); XMLHttpR.open("GET",url,true); XMLHttpR.setRequestHeader("Content-Type","text/html;charset=gbk"); XMLHttpR.onreadystatechange = processResponse; XMLHttpR.send(null); } function processResponse(){ if(XMLHttpR.readyState ==4 && XMLHttpR.status == 200){ document.write(XMLHttpR.responseText); } } sendRequest("编辑器、chrome浏览器。
1、首先,打开html编辑器,新建一个html文件,例如:index.html。
2、在index.html中的<script>;标签,输入js代码:
var now=parseInt(location.href.split('?')[1].split('=')[1]);
$('body').append('<a href="index?page='+ (now-1)+'">;上一页</a>');
$('body').append('<a href="index?page='+ (now+1)+'">;下一页</a>');
3、chrome浏览器运行index.html页面,此时会用js打印出上一页和下一页的a标签。