Mary-Lynne Snedden

make an alert popup on closing a bt - shortcode lightbox?

4 posts in this topic

Hi there

I was wondering if anyone could give me tips on how to create/where to put a user prompt (or alert box) when the user clicks to close. I'd like them to remind them that they need to save their form information before they close the lightbox window.

<script type="text/javascript">

var popit = true;

window.onbeforeunload = function() {

if(popit == true) {

popit = false;

return "If you haven't saved your work, select cancel and save your form before closing.";

}

}

</script>

Thanks for any advice!

Mary-Lynne

Share this post


Link to post
Share on other sites

Hi Mary.

With your requirement, i think you don't need create a shortcode, because shortcode must be added to an article's content or HTML module.

It is not flexible for your requirement.

You only need to add a javascript to your script file for example.

You have a form like this

<div id="form" class="popup">

<form>

<!-- some fields -->

<a class="close" href="3">Close</a>

</form>

</div>

you can add this script

jQuery(document).ready(function($){

$('#form a.close').click(function(){

alert("If you haven't saved your work, select cancel and save your form before closing.");

return false;

});

})

I hope it will help you.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now