Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy javascript-what does this do??

    I'm new to javascript and one of my friends recently came to me with the below javascript. He said it's supposed to save data but said it doesn't work properly. Can any of you confirm that this is what it's supposed to do and if possible what needs to be done to make it work.

    <script language="JavaScript">
    <!--
    if ( top.bActiveXLoaded ) {
    var sSaveChecked = '';
    if (top.bAutoSave)
    sSaveChecked = 'checked = "true"';

    document.write('\
    <table valign="top">\
    <td>\
    <button onClick="top.userRemove();">Discard my data</button>\
    </td>\
    <td>\
    <input type="checkbox" onClick="top.bAutoSave = this.checked;"' + sSaveChecked + '>\
    </td>\
    <td class="save-text">\
    Auto save when exit.\
    </td>\
    </tr>\
    </table>\
    ');
    /* Old buttons, not in use any more.
    <tr>\
    <td>\
    <button onClick="top.userLoad();">Load my data</button>\
    </td>\
    <td>\
    <button onClick="top.userSave();">Save my data</button>\
    </td>\
    */

    } else {
    document.write('Save to disk functionality not loaded.');
    }

    document.onkeydown = trapKeyPress;

    //To hide / show the save functionality from the user.
    function trapKeyPress( eEvent ) {
    if (event.shiftKey) {
    if (document.all.saveDiv.style.visibility != 'visible')
    document.all.saveDiv.style.visibility = 'visible';
    else
    document.all.saveDiv.style.visibility = 'hidden';
    }
    }
    // -->
    </script>

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if that's all you've got, then it won't work because the methods to save the document don't exist anywhere?

    wot are the errors you're getting?
    *keep it simple (TM)

  • #3
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb erm......

    you would've thought i'd ask that wouldn't you but no silly me i didn't. I'll have to try and get hold of him again and get back to you.


  •  

    Posting Permissions

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