Friday, August 31, 2012

Pop up message box

Maybe you see sometimes some sites have message boxes appears on screen. And you wonder how they do it. Here i want to show you how to do it. But it is not pop up window. It is different thing.


You have to use javascript for this. There are 3 type message box you can make. And for those 3 there are 3 different attribute you have to use.

1. Alert
2. Confirm
3. Prompt


Anyway now how to create one of this? This boxes can appears either on first page load or while you leaving a page or any other action. But you can use them with a button too. So we will use this one now. Later on we can practice other ones. But for now with button click we will see how it works.


Alert
To make a button you use an input and give attribute type as button ( there are different ways also create a button ) and use javascript onclick = alert and type something inside parenthesis. Beside parenthesis you can see some other punctuation marks used there. They are also parts of the code. You can also see there is no ending tag only starting one single tag there.

<input type="button" onclick="alert('Hello World !');" value="Click me!" />



Confirm

Confirmation box has one additional button on it next to ok there is also cancel button.

<input type="button" onclick="confirm('Hello World !');" value="Click me!" />



Prompt
Prompt one when you want user type someting in box you use it. I wrote here my site name but you do not need to write it or change it with yours.

<input type="button" onclick="prompt('Hello World !', 'balilandandvillablogspot.com' );" value="Click me!" />

No comments:

Post a Comment

Welcome to Bali Villa & Land




Welcome to Bali Land & Villa


This site is mostly for real estate business and Bali Property but little bit from everything content. If you have any questions please comment on entries or email me directly.

Bali is the one of the most beautiful island in the world. It has increasing number of visitors every year. It is also most profitable property place in the world. And you can find some of those properties and solutions here.

I hope you will enjoy.

Thanks for visiting

Some entries' contents are still weak but will be updated