decodificação e codificação js
A cópia do código é a seguinte:
<! Doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<title> codificação e decodificação de javascript </title>
<script type = "text/javascript">
função gel (id) {
retornar document.getElementById (id);
}
window.onload = function () {
//alert(document.getElementbyId("span1").innerhtml
gel ("btn1"). OnClick = function () {
alerta (codeuri (gel ("span1"). innerhtml));
};
gel ("btn2"). OnClick = function () {
alerta (decodeuri (gel ("span1"). innerhtml));
};
};
</script>
</head>
<Body>
<span id = "span1"> Os três heróis do homem louco estão aumentando! </span>
<input type = "button" id = "btn1" value = "codificado" />
<input type = "button" id = "btn2" value = "decodificado" />
</body>
</html>
Uso de setInterval e Settimeout em js.html
A cópia do código é a seguinte:
<! Doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text/html; charset = utf-8"/>
<title> Usando setInterval e Settimeout em JS </title>
<script type = "text/javascript">
var time = 10;
var id = 0;
função gel (id) {
retornar document.getElementById (id);
}
função dectime () {
if (horário> 0) {
tempo--;
gel ("timespan"). Innerhtml = time;
} outro {
// Limpe o ponteiro
ClearInterval (id);
}
}
window.onload = function () {
id = setInterval (dctime, 1000);
};
</script>
</head>
<Body>
<pan> contagemdown <span id = "timespan" style = "cor: vermelho;"> </span> segundos </span>
</body>
</html>
JS Verifique se a entrada é um número.html
A cópia do código é a seguinte:
<! Doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text/html; charset = utf-8"/>
<Title> JS Verifique se a entrada é um número </title>
<script type = "text/javascript">
window.onload = function () {
document.getElementById ("BTN1"). OnClick = function () {
var i = prompt ("Digite o valor a ser julgado");
//window.alert(i);
if (! isnan (i)) {
window.alert ("é número");
} outro {
window.alert ("não um número");
}
};
}
</script>
</head>
<Body>
<input type = "button" id = "btn1" value = "número do juiz" />
</body>
</html>
JS obtenha dinamicamente, crie e exclua nós.html
A cópia do código é a seguinte:
<! Doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<title> JS obtenha, crie e exclua dinamicamente nós </title>
<script type = "text/javascript">
função gel (id) {return document.getElementById (id); }
window.onload = function () {
gel ("btnProadd"). OnClick = function () {
// Adicione nós filhos em prolist
var linew = document.createElement ("li");
linew.innerhtml = prompt ("Digite a província a ser adicionada");
gel ("prolist"). AppendChild (linew);
// Recunda todos os eventos de clique e delete
DelliondClick ();
};
// clique duas vezes no nó da criança li e exclua-o
function dellionClick () {
// 1. Primeiro obtenha todos os nós filhos
var linodes = gel ("prolist"). Childnodes;
for (var i = 0; i <linodes.length; i ++) {
linodes [i] .OnClick = function () {
//Alert(linodesO
// O seguinte é a maneira correta de excluí -lo, use isso. Porque aquele que desencadeia o evento OnClick é sempre o li que você selecionou
this.parentnode.removeChild (isto);
};
}
}
};
</script>
</head>
<Body>
<ul id = "prolist">
<li> Shanxi </li>
<li> Henan </li>
<li> Pequim </li>
</ul>
<input type = "button" value = "adicionar nova província" id = "btnproadd" />
</body>
</html>
Uso de setInterval e Settimeout em js.html
A cópia do código é a seguinte:
<! Doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text/html; charset = utf-8"/>
<title> Usando setInterval e Settimeout em JS </title>
<script type = "text/javascript">
var time = 10;
var id = 0;
função gel (id) {
retornar document.getElementById (id);
}
função dectime () {
if (horário> 0) {
tempo--;
gel ("timespan"). Innerhtml = time;
} outro {
// Limpe o ponteiro
ClearInterval (id);
}
}
window.onload = function () {
id = setInterval (dctime, 1000);
};
</script>
</head>
<Body>
<pan> contagemdown <span id = "timespan" style = "cor: vermelho;"> </span> segundos </span>
</body>
</html>
JS Adicione dinamicamente dados da tabela.html
A cópia do código é a seguinte:
<! Doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<title> Adição dinâmica de dados de tabela </ititle>
<script type = "text/javascript">
var malarr = [
{"Title": "A C# Problem", "Name": "Zhang San", "Date": "2014-03-21"},
{"Title": "A JavaScript Problem", "Name": "Li si", "Date": "2014-03-21"},
{"Title": "A C Pergunta", "Nome": "55", "Date": "2014-03-21"},
{"Title": "A C ++ Pergunta", "Nome": "Zhao Liu", "Date": "2014-03-21"}
];
window.onload = function () {
var tab = document.getElementById ("TB");
// Adicione o método de travessal de loop do Mailer à tabela em TR
for (var rowindex = 0; rowIndex <malor.length; rowIndex ++) {
var tr = document.createElement ("tr");
var th1 = document.createElement ("th");
var th2 = document.createElement ("th");
var th3 = document.createElement ("th");
var th4 = document.createElement ("th");
th1.innerhtml = "<Tipo de entrada = 'Caixa de seleção'/>";
th2.innerhtml = MaileRr [RowIndex] .title;
th3.innerhtml = MaileRr [RowIndex] .Name;
th4.innerhtml = MaileRr [RowIndex] .Date;
tr.appendChild (Th1);
tr.appendChild (Th2);
tr.appendChild (Th3);
tr.appendChild (Th4);
tab.appendChild (tr);
}
};
</script>
</head>
<Body>
<tabela id = "tb" style = "colapso de borda: colapso;">
<tr>
<th> sequência </th>
<th> título </th>
<th> Envie Mailer </th>
<th> Enviar tempo </th>
</tr>
<!-Aumento do loop->
</tabela>
</body>
</html>