신수용

10 JavaScript for Web Broswer

<html>
<head>
<script type="text/javascript">
function message(){
alert("This alert box was called with the onload event");
}
</script>
</head>
<body onload="message()">
<script type="text/javascript">
document.write("This message is written by JavaScript");
</script>
</body>
</html>
<html>
<head>
<script type="text/javascript" src="xxx.js"></script>
<script type="text/javascript">
function message(){
alert("This alert box was called with the onload event");
}
</script>
</head>
<body onload="message()">
</script>
</body>
</html>
<html>
<head>
</head>
<body>
<script type="text/javascript">
var str="Hello world!";
//look for "Hello"
var patt=/Hello/g;
var result=patt.exec(str);
document.write("Returned value: " + result);
//look for "W3Schools"
patt=/W3Schools/g;
result=patt.exec(str);
document.write("<br />Returned value: " + result);
</script>
</body>
</html>
<html>
<head>
</head>
<body>
<script type="text/javascript">
// location
location.assign("http://www.google.com"); // ּ ̵
</script>
</body>
</html>
<html>
<head>
</head>
<body>
<script type="text/javascript" src="alert.js">
</script>
</body>
</html>
//window객체는 window. 생략 가능
alert("test"); // 메시지 창 띄움
window.open('','','width=200,height=100') // 새창 띄우기
if (confirm("Are you sure?")) {
// Yes/No를 묻는 다이얼로그 창 띄움. Yes일 때만 true
}
var name = prompt("Enter name"); // 사용자의 입력 받는 창 띄움
document.write("This message is written by JavaScript");