Enjoy an ad free experience by logging in. Not a member yet? Register.
|
|
Results 1 to 2 of 2
-
04-06-2016, 10:43 PM #1New to the CF scene
- Join Date
- Apr 2016
- Posts
- 2
- Thanks
- 0
- Thanked 0 Times in 0 Posts
Need Alert Popup while clicking Important Link's
Hi Team,
I'm working on a simple HTML project in my office. Now my requirement is whenever I'm clicking a important links then i need a pop up stating that "Be Careful" or some other alert message.
Kindly help me how to give this.
Note:
In one file i have multiple links, but when ever i click one particular link i need an alert not for the others.
Thanks in advance.
-
04-06-2016, 11:57 PM #2
This should probably be done using Javascript and should therefore be moved to the appropriate section. You can probably google this and find some different solutions.
However, I'm bored so here's a basic example:
/* Note! I'm not strong with Javascript so this might not be the most efficient way to accomplish your task but it does work in modern browsers. */
Javascript:
HTML:Code:var elems = document.getElementsByClassName('confirmation'); var confirmLink = function (e) { if (!confirm('Please be careful visiting external links. Are you sure you want to continue?')) e.preventDefault(); }; for (var i = 0, l = elems.length; i < l; i++) { elems[i].addEventListener('click', confirmLink, false); }
Code:<a target="_blank" href="Google" class="confirmation">click me</a>



Reply With Quote
