On my online page I have a simple alert message. I basically need to change the title but I've read that I cannot do that.
Here's the code:
<script>alert("My Message Here");</script>
In the alert message I get the url of my website and then the message under it.
What is the quickest alternative to having a javascript alert?
Thanks
Add hidden div aligned with your elements and show the message on hidden div's instead of alert box.
The standard alert box in JavaScript does not provide the option to apply CSS. To style your alert box, you need to create a custom one first. The custom alert box will be created using jQuery and styles will be applied to CSS.
JavaScript has three kind of popup boxes: Alert box, Confirm box, and Prompt box.
I like this one a lot: http://t4t5.github.io/sweetalert/
It does not depend on any other JavaScript library and is highly customizable. Supports different kinds of message pop-ups, implements a prompt pop-up and allows message chaining.
The alternative is a javascript 'modal window'. Having a google for that should turn up a plethora of options.
This method enables you to style a div however you like and to have that shown in place of the alert box. If you've ever seen a lightbox, the effect and idea is very similar.
They are all very easy to implement. Most often just requiring the inclusion of the script, some CSS and a line of jquery to initialise the modal window on the specific DIV.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With