Object是获取的元素对象,如通过document.getElementById("ID")获取的元素。
2.注意书写,innerHTML区分大小写。
2.注意书写,innerHTML区分大小写。
2016-03-24
<script>
var mynum = 30;
alert("hello!");
alert(mynum);
</script>
var mynum = 30;
alert("hello!");
alert(mynum);
</script>
2016-03-24
function openWindow(){
var da=confirm("是否打开新窗口?");
if(da==true){
var url=prompt("请输入一个网址:","http://www.imooc.com");
if(url!=null){
window.open('url','_blank','width=400,height=500, menubar=no,toolbar=no');
}else{
alert("请不要乱输入网址!");
}
}else{
alert("不打开也乱点!手痒么!");
}
}
//数字限制能用
var da=confirm("是否打开新窗口?");
if(da==true){
var url=prompt("请输入一个网址:","http://www.imooc.com");
if(url!=null){
window.open('url','_blank','width=400,height=500, menubar=no,toolbar=no');
}else{
alert("请不要乱输入网址!");
}
}else{
alert("不打开也乱点!手痒么!");
}
}
//数字限制能用
<head>
<script type="text/javascript>
function contxt()//定义contxt函数
{alert("哈哈,函数调用了!")
}
</script>
</head>
<body>
<form>
<input tyle="button" value="点击我” onclick="contxt()"/></form>
</body>
<script type="text/javascript>
function contxt()//定义contxt函数
{alert("哈哈,函数调用了!")
}
</script>
</head>
<body>
<form>
<input tyle="button" value="点击我” onclick="contxt()"/></form>
</body>
2016-03-24
var mydiv=document.getElementById("txt");
function col(){
mydiv.style.color="red";
mydiv.style.backgroundColor="#ccc";
}
function wid(){
mydiv.style.width="300";
mydiv.style.height="400";
function disn(){
mydiv.style.display="none";
}
function col(){
mydiv.style.color="red";
mydiv.style.backgroundColor="#ccc";
}
function wid(){
mydiv.style.width="300";
mydiv.style.height="400";
function disn(){
mydiv.style.display="none";
}
<input type="button" value="改变颜色" onClick="col()">
<input type="button" value="改变宽高" onClick="wid()">
<input type="button" value="隐藏内容" onClick="disn()">
<input type="button" value="显示内容" onClick="disb()">
<input type="button" value="取消设置" onClick="nono()">
<input type="button" value="改变宽高" onClick="wid()">
<input type="button" value="隐藏内容" onClick="disn()">
<input type="button" value="显示内容" onClick="disb()">
<input type="button" value="取消设置" onClick="nono()">
进行页面显示初始化的js必须放在head里面,因为初始化都要求提前进行(如给页面body设置css等);而如果是通过事件调用执行的function那么对位置没什么要求的。
2016-03-24
function openWindow(){
var mychar="默认为http://www.imooc.com/";
var myTure = alert("是否打开");
var myShuru = prompt(mychar,"http://www.imooc.com/");
if(myShuru != null){
window.open('http://www.imooc.com/','_blank','width=400,height=500,menubar=no,toolbar=no')
}
}
var mychar="默认为http://www.imooc.com/";
var myTure = alert("是否打开");
var myShuru = prompt(mychar,"http://www.imooc.com/");
if(myShuru != null){
window.open('http://www.imooc.com/','_blank','width=400,height=500,menubar=no,toolbar=no')
}
}
function hidetext()
{
var mychar = document.getElementById("con").style.display;
if(mychar=="block"){
document.getElementById("con").style.display="none"
}else{
document.getElementById("con").style.display="block"
}
}
{
var mychar = document.getElementById("con").style.display;
if(mychar=="block"){
document.getElementById("con").style.display="none"
}else{
document.getElementById("con").style.display="block"
}
}
2016-03-23
<p onMouseOver="window.open('url')">万恶的弹窗</p>
2016-03-23