HTMLウィンドウalert()メソッド
HTMLウィンドウのalert()メソッドは、定義されたメッセージとHTMLドキュメントの[OK]ボタンを含むアラートボックスを表示します。
構文
以下は構文です-
alert(“message”);
HTMLウィンドウのalert()メソッドの例を見てみましょう-
例
<!DOCTYPE html>
<html>
<head>
<style>
body {
color: #000;
height: 100vh;
background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%) no-repeat;
text-align: center;
padding: 20px;
}
.btn {
background: #db133a;
border: none;
height: 2rem;
border-radius: 2px;
width: 40%;
display: block;
color: #fff;
outline: none;
cursor: pointer;
margin: 1rem auto;
}
</style>
</head>
<body>
<h1>HTML Window alert() Method</h1>
<button class='btn' onclick="add()">Click me to open an alert box</button>
<script>
function add() {
alert("Hello! I'm an alert box");
}
</script>
</body>
</html> 出力
「アラートボックスを開くために作成する」をクリックします 」ボタンをクリックしてアラートボックスを開きます。
-
HTMLウィンドウmoveBy()メソッド
HTMLウィンドウのmoveBy()メソッドは、現在の座標を基準にしてウィンドウを移動します。 構文 以下は構文です- window.moveBy(x,y) ここで、xとyは、ウィンドウを水平方向と垂直方向にそれぞれピクセル単位で移動する値を定義します。 HTMLウィンドウの例を見てみましょうmoveBy()メソッド- 例 <!DOCTYPE html> <html> <style> body { color: #000; height: 10
-
HTML DOMウィンドウstop()メソッド
HTML DOMウィンドウstop()は、ブラウザの停止ボタンをクリックせずにウィンドウのリソースの読み込みを停止する機能をユーザーに提供します。 構文 以下は構文です- window.stop() 例 HTML DOMウィンドウのstop()メソッドの例を見てみましょう- <!DOCTYPE html> <html> <head> <title>HTML DOM Window stop()</title> <style> * { padding: 2