0

In a static html page i want to do following actions:

  1. as the url is entered first I want to display the terms and conditions using window.alert("TERMS AND CONDITIONS").
  2. In the dialogue box I want two buttons "agree" and "dont agree". If agree is pressed I want to use window.location.assign("next page url") .And if dis agree is pressed I want to use window.close("","_self")

I'm a total beginner and have minimum knowledge of Javascript.

Thank you in advance.

sigdelsanjog
  • 528
  • 1
  • 11
  • 30
  • 3
    Use some library for modal boxes instead. – Sirko Jul 20 '15 at 11:55
  • 1
    try https://github.com/kylefox/jquery-modal – Chen Kinnrot Jul 20 '15 at 11:55
  • 1
    http://bootboxjs.com/ – AshBringer Jul 20 '15 at 11:59
  • You can override the default alert with `window.alert = function (msg) { console.log('now alert goes to log: ', msg); }`. So, you will need to build your own alert popup from scratch – Jose Rui Santos Jul 20 '15 at 12:04
  • 2
    @ChenKinnrot When I use your code from the downloaded folder it works perfectly, When I copy those codes in new file and press Open model it just adds #ex1 to the url. – sigdelsanjog Jul 20 '15 at 17:45
  • @ChenKinnrot I see your code works completely and your model is attractive. But I am having problem in even understanding everything you already mention. Would you please answer it so that I can understand it clearly and also accept the answer. Thanks in advance – sigdelsanjog Jul 20 '15 at 18:10

3 Answers3

2

You can not modifiy the default alert dialog.

But instead, you can use one of the many Dialogs made for jquery and other libraries.

http://www.sitepoint.com/14-jquery-modal-dialog-boxes/

Oscar
  • 13,594
  • 8
  • 47
  • 75
1

The alert box is a system object, and not subject to CSS. The jQuery UI Modal box does a lot of the work for you Link.

Shrinivas Pai
  • 7,491
  • 4
  • 29
  • 56
1

if you want a basic browser graphic u can use

window.confirm("TERM AND CONDITIONS");

that return true or false based on action. For more advaced usage check jquery dialogs boxes (docs https://jqueryui.com/dialog/ ) or bootstrap (docs http://nakupanda.github.io/bootstrap3-dialog/)

Vanojx1
  • 5,574
  • 2
  • 23
  • 37