Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Need help on javascript alert box

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #37062
    dalecooper
    Member

    Hi,

    I came up with this little script to show an alert box when a page is called :


    It suits me very well but as I am very very new in JS, I don’t know how to have it display only one button that redirects to the previous page. For now, I have “ok” and “cancel” buttons, and here this is the “cancel” button that I would like to keep.

    Anyone knows what I have to change ?

    #98569
    karlpcrowley
    Participant

    Hey, The 3 basic dialog boxes (alert, prompt, confirm) are built into the browser so unfortunately there’s not a whole lot you can do

    There are some library out there for making your own dialog boxes

    Here’s a couple of nice jQuery ones
    http://dev.iceburg.net/jquery/jqModal/
    http://www.ericmmartin.com/projects/simplemodal/

    #98570
    dalecooper
    Member

    Arf, I was trying to have a website full CSS without jquery at all (some JS, but hey ;) ).

    Anyway, thank you Karl, I’ll try one of your solutions.

    #98574
    dalecooper
    Member

    Ok, so here’s the issue with your suggestion: I use formmail to allow people to contact me, and the script only allow error messages to be redirected to another HTML page, not the main page. So I am not able to redirect to a div for instance.

    What I would like is a simple modal dialog to open when an error occured with the form. For now, I found the JS solution described above which is called when error.html is opened. So no new page shown, just the modal dialog but with “ok” and “cancel” (“ok” is useless for my use).

    With the jquery modal dialogs you propose, It would mean opening a new page, showing the modal dialog, and then returning to the main page. It would be redundant to have both a new page, and a modal dialog to open when an error occur. I only need a simple dialog without the “cancel” button.

    Can’t I achieve this with alert or prompt functions ???

    #98575
    dalecooper
    Member

    Oups, double post :P

    Just to say that, Karl, I used ALERT instead of CONFIRM and it just does what I want.

    Thanks thanks thanks :D

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.