Difference between html popup and javascript popup

Posted on

When any question is asked in an interview most of the time people are confused between the javascript popup and html popup. Sometimes people call both as html popup. Lets see what are the difference between these two.

Javascript Popup

Javascript popup is an small window displayed using javascript function. This is done to alert the user with some information or to record short responses from user. Sometimes developer add this in their code for debugging purpose and will forget to remove it while check-in the code. You won't be able to see any internal structure or html code block if you inspect it. It's just a alert window that is displayed with some message. There are different types of javascript popup window or alert boxes.
1. Alert Box

This is used to alert user with some information and it will have a Ok button which is used to close this alert box to proceed.
alert box example
2. Confirm Box

The confirm box is often used to verify or accept some information from user. Here user has got two option to chose. When a confirm box displayed, the user will have to click either Ok or Cancel button to close and proceed. These two buttons returns two different response from user. If the user click on Ok, the box returns response as true. If the user clicks on Cancel, the box returns response as false.
example of confirm box
3. Prompt Box

This is used to get some information from user before entering a page. When a prompt box is displayed, the user will have to click either on Ok or Cancel button to proceed after entering the requested input value. If the user click on Ok button the prompt box returns the input value entered by user. If the user click on Cancel button the prompt box returns null value.
prompt box example
One important point to remember is these javascript popup will block the user interaction on browser until it is closed. Hence this popup boxes should be closed with the correct responses method available in that popup box ie Ok or Cancel button.

HTML Popup

HTML popup is a customized popup created using the HTML, CSS and javascript. It can be of any size and design. It is created to add better user experience. Unlike javascript, it's part of application hence the interaction will not block when it is open. It can contain a single notification or a huge transaction.

You can inspect the code of the HTML popup. Since javascript requires a special class to handle while doing automation using selenium, you don't require any special class to handle HTML popup.
example of HTML popup