Getting Started with JavaScript (a) popup box

Source: Internet
Author: User
Tags script tag

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.