js怎么写页面
- 综合知识
- 关注:3.3W次
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. 网页上的“上一页,下一页”JS代码怎么写需要准备的材料分别是:电脑、html编辑器、chrome浏览器。
1、首先,打开html编辑器,新建一个html文件,例如:index.html。 2、在index.html中的<script>标签,输入js代码: var now=parseInt(location.href.split('?')[1].split('=')[1]); $('body').append('上一页'); $('body').append('下一页'); 3、chrome浏览器运行index.html页面,此时会用js打印出上一页和下一页的a标签。
3. 我要js调用整个页面,应该怎样写JSfunction 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("、top.html、bottom.html为例来具体说明如何做。
frame.html 由上(top.html)下(bottom.html)两个页面组成,代码如下: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">