View Full Version : javascript-what does this do??

08-20-2004, 11:49 AM
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"';

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

} 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';
document.all.saveDiv.style.visibility = 'hidden';
// -->

08-20-2004, 12:30 PM
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?

08-20-2004, 12:52 PM
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.