Reputation: 175
I tries to used this code to make an alert when user click on the link. However, this function only work with Chrome and Internet Explorer but doesn't work in Firefox.
Please refer to the code below :
jQuery(function($) {
$(document).ready(function() {
$(".disableGA").on("click", function() {
event.preventDefault();
alert("Google Analytics was disabled");
window.location.href = 'javascript:gaOptout()';
});
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a class="disableGA">Disable Google Analytics</a>
Upvotes: 0
Views: 89
Reputation: 13417
Please pass event
to the function and try again
<script>
jQuery(function ($) {
$( document ).ready(function() {
$(".disableGA").on("click", function(event){
event.preventDefault();
alert("Google Analytics was disabled");
window.location.href='javascript:gaOptout()';
});
});
});
</script>
Upvotes: 4