Home › Forums › JavaScript › Need help on javascript alert box
- This topic is empty.
-
AuthorPosts
-
March 9, 2012 at 3:43 am #37062
dalecooper
MemberHi,
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 ?
March 9, 2012 at 3:54 am #98569karlpcrowley
ParticipantHey, 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/March 9, 2012 at 3:58 am #98570dalecooper
MemberArf, 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.
March 9, 2012 at 4:39 am #98574dalecooper
MemberOk, 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 ???
March 9, 2012 at 4:43 am #98575dalecooper
MemberOups, 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
-
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.