js怎麼寫頁面
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">