Results 1 to 2 of 2

Thread: window.onbeforeunload

  1. #1
    Join Date
    Jun 2011

    Exclamation window.onbeforeunload

    If i'm using a script like this for a comment section:

    <script>window.onbeforeunload = function() { return "Sure?"; }</script>

    I don't want it to ask if they select the "add comment" button... it's basically a reminder for if they begin to navigate away without adding the comment.. any help would be greatly appreciated. Thanks.

    Is it causing conflict because i already have an onClick event?

    <input type='button' value='Clear' onClick="setval('CATEGORY',''); document.getElementById('CATNAME').innerHTML = '';">

  2. #2
    Join Date
    Jun 2011
    here's the whole form if it will make it any clearer...

    HTML Code:
    window.onbeforeunload = function() {
        return 'Are you sure you want to navigate away from this page?';
    <div class='module_header'>New Comment | <a class='f' href='<?php echo matry::here_to('lookup'); ?>'>Cancel</a></div>
    <form action='<?php echo matry::here(); ?>' id="rita" method='post' onchange="changes=true" onsubmit="var arr = new Array('NOTE1'); return mandatory(this, arr);">
    <table class='edit'>
    <tr><td>Note1 <?php tbox('NOTE1', 60, 4, 250); ?></td></tr>
    <tr><td>Note2 <?php tbox('NOTE2', 60, 4, 250); ?></td></tr><tr><td /></tr>
    <tr><td>Note3 <?php tbox('NDATA', 60, 6, 6000); ?></td></tr>
    <tr><td><?php echo lookup_link('Category', 'category', 'CATEGORY=Category&CATNAME=Description'); ?> <?php inp('CATEGORY',2); ?>
    	<input type='button' value='Clear' onClick="setval('CATEGORY',''); document.getElementById('CATNAME').innerHTML = '';">
    	<span id='CATNAME'></span></td></tr>
    <tr><td><?php echo button::save('Add Comment'); ?></td></tr>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center