注意-->JS中调用样式时,使用连字符的属性名称需要改为驼峰式的名称才能正常使用,如mychar.style.backgroundColor,css中的background-color要更改为backgroundColor,去连字符,第二个单词首字母大写。
2015-12-09
已采纳回答 / 木子舟义
prompt("请输入网址:", 这个逗号写错了alert("再见"); 最后的分号写错了 alert("再见"); 分号写错了 onclick="openWindow()" 而不是ok = “openWindow()"<...code...>
2015-12-09
//定义"隐藏内容"的函数
function hideCOntext(){
var hid=document.getElementById("txt");
hid.style.display="none";}
//定义"显示内容"的函数
function display(){
var disp=document.getElementById("txt");
disp.style.display="block";}
function hideCOntext(){
var hid=document.getElementById("txt");
hid.style.display="none";}
//定义"显示内容"的函数
function display(){
var disp=document.getElementById("txt");
disp.style.display="block";}
//定义"改变颜色"的函数
function changeColor(){
var txColor=document.getElementById("txt");
txColor.style.color="green";
txColor.style.backgroundColor="pink";}
//定义"改变宽高"的函数
function changeWH(){
var cWH=document.getElementById("txt");
cWH.style.height="300px";
cWH.style.width="200px";}
function changeColor(){
var txColor=document.getElementById("txt");
txColor.style.color="green";
txColor.style.backgroundColor="pink";}
//定义"改变宽高"的函数
function changeWH(){
var cWH=document.getElementById("txt");
cWH.style.height="300px";
cWH.style.width="200px";}
<script type="text/javascript">
function rec(){
var mymessage=confirm("你是妹纸吗?") ;
if(mymessage==true)
{
document.write("你是女士!");
}
else
{
document.write("你是男士!");
}
}
</script>
function rec(){
var mymessage=confirm("你是妹纸吗?") ;
if(mymessage==true)
{
document.write("你是女士!");
}
else
{
document.write("你是男士!");
}
}
</script>
2015-12-09
<script type="text/javascript">
function rec(){
var mychar="I love JavaScript";
alert(mychar);
}
</script>
function rec(){
var mychar="I love JavaScript";
alert(mychar);
}
</script>
2015-12-09
function openWindow(){
var open=confirm("确定打开新窗口?");
if(open==true){var openConfirm=prompt("确定打开以下网址?","http://www.imooc.com/");
if(openConfirm !=null){window.open('http://www.imooc.com/','_blank','width=400px,height=500px,menubar=no,toolbar=no')}else{}} else{}}
var open=confirm("确定打开新窗口?");
if(open==true){var openConfirm=prompt("确定打开以下网址?","http://www.imooc.com/");
if(openConfirm !=null){window.open('http://www.imooc.com/','_blank','width=400px,height=500px,menubar=no,toolbar=no')}else{}} else{}}