关于函数之间的值的引用问题
<script type="text/javascript">
function openWindow(){
var message=confirm("are u sure to open a new window?");
if(message==true){
var newWebsite=prompt("enter a new website:","http://www.imooc.com/");
if(newWebsite!=null){
window.open(newWebsite,'_blank','width=400px,height=500px,toolbar=no,menubar=no');
}else{document.write("over again!");}
}else{
document.write("nnothing to do!");
}
}
function closeWindow(){
var clOpen=confirm("are u sure to close the window?");
if(clOpen==true){
newWebsite.close();//请问我该怎样引用到另一个函数里面定义的newWensite呢??
}else{
document.write("the window isn't closed!");
openWindow();
}
}
// 新窗口打开时弹出确认框,是否打开
// 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/
//打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
<input type="button" value="close the wb" onclick="closeWindow()" />
</body>
</html>我这样定义了两个函数,一个打开一个关闭,可是我关闭的函数里面该怎样引用打开函数里面的值呢,还是需要重新定义?