Today, I want JavaScript to do a pop-up box with a Web page, though it doesn't have any eggs.
Effect, pop up a "Hello World" box.
1. Create a new HTML page,
<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Title</title></Head><Body></Body></HTML>
2. There are three ways to pop up the box:
Mode one: (not recommended) inline events, directly in the <body> write pop-up information. Pop-up mode, open page, click button, pop up
<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Title</title></Head><Body> <inputtype= "button"name=""onclick= "alert (' OK '!);"></Body></HTML>
Mode two: page script tag embedding. Pop-up mode, open the page directly popup;
<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Title</title> <Scripttype= "Text/javascript"> varmessage= "Hello"alert (message); </Script></Head><Body> </Body></HTML>
Mode three: external introduction. Pop-up mode, open page directly popup
<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Title</title> <Scripttype= "Text/javascript"src= "Js/test1.js"></Script></Head><Body> </Body></HTML>
Then create a new file in the JS directory test1.js
Alert (' Hello World ');
Getting Started with JavaScript (a) popup box