本文目錄一覽:
- 1、用javascript編寫一個程序,要求:網頁運行的時候彈出對話框:歡迎進入
- 2、JS作業題 ,附代碼
- 3、用javascript和html完成的作業,問怎樣使當在登錄界面輸入預定的密碼後會進入·只有登陸成功四字網頁
- 4、使用JavaScript編寫網頁(很簡單,入門的作業)
- 5、JS代碼作業
用javascript編寫一個程序,要求:網頁運行的時候彈出對話框:歡迎進入
html
head
title作業/title
script
function welcome(){
window.alert(“歡迎進入”);
}
/script
/head
body onload=”welcome();”
這是老師布置的彈窗作業
/body
/html
說明:把以上直接保存為html網頁文件即可
JS作業題 ,附代碼
!DOCTYPE html
html
head
meta charset=”utf-8″ /
title無標題文檔/title
style
#group1 {
width: 350px;
padding-left: 20px;
line-height: 30px;
}
.spanCss {
font-size: 28px;
}
/style
script
var ck=function(cc){
var cs=group1.querySelectorAll(“input[type=checkbox]”);
var num=0;
for(var i=0;ics.length;i++){
if(cs[i].checked){
num++;
}
}
cc.innerHTML=cs.length+”個選項,選中”+num+”個”;
}
/script
/head
body
p大學學習目的:/p
fieldset id=”group1″
legend
label
input type=”checkbox” /學習知識,提高技能/label
br /
label
input type=”checkbox” /培養終生學習能力/label
br /
label
input type=”checkbox” /促進心智成長/label,增強表達、溝通、協作能力
br /
label
input type=”checkbox” /構建人脈/label
br /
/legend
/fieldset
p要求實現的功能:/p
pspan class=”spanCss” onclick=”ck(this)”單擊這裡顯示:?個選擇項,選中?個/span
/p
/body
/html
用javascript和html完成的作業,問怎樣使當在登錄界面輸入預定的密碼後會進入·只有登陸成功四字網頁
script type=”text/javascript”
function check(){
var oldpass = “abcdefg”;
var currpass = document.getElementById(‘password’).value; //獲取文本框中輸入的值
id(currpass.trim()!=null){
if(oldpass==currpass){
window.location.href=”success.html”; //如果密碼匹配,進入success.html頁面
}
}
}
/script
在登錄頁面中放入一個文本框input type=”text” id=”password” name=”password”
和一個按鈕input type=”button” id=”login” name=”login” value=”login” onClick=”check()”
然後還需要創建一個登錄成功頁面success.html,在頁面中顯示:登錄成功。
使用JavaScript編寫網頁(很簡單,入門的作業)
html
title計算園面積/title
script language=”JavaScript”
function c(frm)
{
var r=frm.t1.value;
var res=Math.PI*r*r;
alert(res)
}
/script
/head
body
form name=”form1″
p請輸入圓的半徑:
input type=”text” name=”t1″ /
/p
input type=”submit” name=”Submit” value=”計算” onClick=” return c(this.form)”
/form
/body
/html
JS代碼作業
這是1.html
!DOCTYPE html
html
head
meta charset=”UTF-8″
script src=””/script
style type=”text/css”
/style
/head
body
input type=”text” name=”name1″br /br /
input type=”text” name=”name2″br /br /
input type=”submit” id=”sub”
/body
script
$(function(){
$(“#sub”).click(function(){
if(confirm(“確定要提交嗎”)) {
var val1 = $(“[name=’name1′]”).val();
var val2 = $(“[name=’name2′]”).val();
window.location.href=”2.html?name1=”+val1+”name2=”+val2;
}
return false;
});
});
/script
/html
2.html
!DOCTYPE html
html
head
meta charset=”UTF-8″
script src=””/script
style type=”text/css”
/style
/head
body
/body
script
$(function(){
var url = location.search;
alert(url);
});
/script
/html
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/278282.html