1 Javascript - Popup Boxes Sun Mar 18, 2012 5:31 am
Mr.Joker
Mr. WebArtz
Javascript - Popup Boxes How to use JavaScript popup boxes |
Hello again, I am Mr.Joker, and today I will teach you how to use popup boxes with javascript. Like always i have to say something about it. Popup boxes are as name say, boxes that jump out as soon as you do something on web page. You allready saw many popup boxes I am sure but there is 3 of them you have to know. -window.alert() -window.confirm() -window.prompt() Lets start from the first one.
Here we say i writen window first. Window is as you know a window, so basicly I say to web browser that window is an object (you will learn later about objects). I add dot because i want to declare what to do with a window. So i said alert. This means that as soon as this javascript is runed, a window will appear on our screen with a massage we have entered inside quotation marks. Lets move on.
Here we start with a variable x that has value of some window that will popup confirm box on our screen with text in quotation marks. So, this variable will popup some box on the screen and ask as a question. There will be two choices, Ok and cancel. Then if i choose one of them nothing will happen. Why? Because i didnt declared what will happen yet. So i make a if&else statement. I say, If x (and x is in this case OK button by default) then write on the screen first message, if its not ok, so if its cancel button pressed then do else code. Its really simple. And here we go the last example:
We have here variable x again with value of window that will popup some prompt window. What is prompt window? Its a window that ask you a question and leave you a textbox to enter some value again. That value you enter will become value of variable x. So I say in next line that document write : "Your name is + variable x" and variable x is name you enter in prompt box. Try it and you will be stuned how simple is that |
Notice : This tutorial is copyrighted by WebArtz Forum. You may not publish it on anywhere without written permission from the administrators. |