已采纳回答 / forever868
<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" Content="text/html; charset=utf-8" /><title>javascript</title><style type="text/css">body{font-size:12px;}#txt{ height:400px; width:600px; border:#3...
2016-03-18
function openWindow(){
if(confirm("是否打开新窗口?")){
var url=prompt("请输入网址:","http://www.imooc.com/");
window.open('url','_blank','width=400, height=500,menubar=no, toolbar=no');
}
}
if(confirm("是否打开新窗口?")){
var url=prompt("请输入网址:","http://www.imooc.com/");
window.open('url','_blank','width=400, height=500,menubar=no, toolbar=no');
}
}
<p id="p1">我是第一段文字</p>
<p id="p2">我是第二段文字</p>
<script type="text/javascript">
document.write("hello");
document.getElementById("p1").style.color="blue";
<p id="p2">我是第二段文字</p>
<script type="text/javascript">
document.write("hello");
document.getElementById("p1").style.color="blue";
2016-03-17
document.write("hello");
document.getElementById("p1").style.color="blue";
document.getElementById("p1").style.color="blue";
2016-03-17
<script type="text/javascript">
var mychar=document.getElementById("con"); ;
document.write("原标题:"+mychar.innerHTML+"<br>"); //输出原h2标签内容
mychar.innerHTML="Hello,world!";
document.write("修改后的标题:"+mychar.innerHTML); //输出修改后h2标签内容
</script>
var mychar=document.getElementById("con"); ;
document.write("原标题:"+mychar.innerHTML+"<br>"); //输出原h2标签内容
mychar.innerHTML="Hello,world!";
document.write("修改后的标题:"+mychar.innerHTML); //输出修改后h2标签内容
</script>
2016-03-17
已采纳回答 / qq_北葵_0
错误一: if(mywin1="http://www.imooc.com/"); 后面那个分号不能用。每一个if语句后面跟的else如果没有要表达的话,可以省略,也可以加上(else;)错误二:你在写网址的时候应该切换成英文输入,而不是中文输入。(这是打不开的主要原因)错误三:window.open( )括号里应该是单引号,如果你要在新的窗口中打开的话要加一个('_blank')
2016-03-17
<title>浏览器对象</title>
<script type="text/javascript">
function openWindon(){
if(confirm("确定打开新窗口吗?")){
var url = prompt("请输入一个网址","http://www.imooc.com/");
window.open( url,"_blank","toolbar=no, menubar=no, scrollbars=yes, width=400, height=400");
}
}
</script>
<script type="text/javascript">
function openWindon(){
if(confirm("确定打开新窗口吗?")){
var url = prompt("请输入一个网址","http://www.imooc.com/");
window.open( url,"_blank","toolbar=no, menubar=no, scrollbars=yes, width=400, height=400");
}
}
</script>