HighDots Forums  

Re: Onclick problem

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: Onclick problem in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Richard Cornford
 
Posts: n/a

Default Re: Onclick problem - 10-16-2003 , 04:12 PM






"Shock" <shock56 (AT) charter (DOT) net> wrote

<snip>
Quote:
function funPrintButtons() {

document.write("<input type = 'button' value='Grade Quiz'
onclick='funGradeQuiz()'>");
document.write("<input type = 'button' value='Refresh Quiz'
onclick='location.reload()'>");

} // end funPrintButtons
snip
body
onLoad = "funInitialize(); funPrintQuestions(); funPrintButtons();"
snip

You are calling document.write after the original document has been
closed (in the onload event). That will result in the current document
being cleared and replaced, and when it is cleared all of the JavaScript
functions go with it.

Richard.




Reply With Quote
  #2  
Old   
Shock
 
Posts: n/a

Default Re: Onclick problem - 10-16-2003 , 05:25 PM






Sorry, I am not sure I understand. I thought document.write simply wrote
the line into the document. When was the document closed?

Shock


"Richard Cornford" <Richard (AT) litotes (DOT) demon.co.uk> wrote

Quote:
"Shock" <shock56 (AT) charter (DOT) net> wrote in message
news:votqdda7n8fh65 (AT) corp (DOT) supernews.com...
snip
function funPrintButtons() {

document.write("<input type = 'button' value='Grade Quiz'
onclick='funGradeQuiz()'>");
document.write("<input type = 'button' value='Refresh Quiz'
onclick='location.reload()'>");

} // end funPrintButtons
snip
body
onLoad = "funInitialize(); funPrintQuestions(); funPrintButtons();"
snip

You are calling document.write after the original document has been
closed (in the onload event). That will result in the current document
being cleared and replaced, and when it is cleared all of the JavaScript
functions go with it.

Richard.





Reply With Quote
  #3  
Old   
Lasse Reichstein Nielsen
 
Posts: n/a

Default Re: Onclick problem - 10-16-2003 , 05:44 PM



"Shock" <shock56 (AT) charter (DOT) net> writes:

Quote:
Sorry, I am not sure I understand. I thought document.write simply wrote
the line into the document. When was the document closed?
The document was closed when it finished loading, i.e., *just* before
the document's onload event happens.

While loading the page, the page is processed from top to bottom. A
script is executed when this process reaches it, and a document.write
inserts content between the script that calls it and the remaining,
unprocessed, code.

When processing reaches the end of the document, it is finished. This
closes the document and then calls the onload handler. That means that
document.write's in the onload handler will reopen, and thereby clear,
the document.

/L
--
Lasse Reichstein Nielsen - lrn (AT) hotpop (DOT) com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'


Reply With Quote
  #4  
Old   
Shock
 
Posts: n/a

Default Re: Onclick problem - 10-16-2003 , 05:46 PM



Ok, I understand what you mean, but now I am confused on how to get the
functions to work without actually calling them.

Thanks,

Shock
"Lasse Reichstein Nielsen" <lrn (AT) hotpop (DOT) com> wrote

Quote:
"Shock" <shock56 (AT) charter (DOT) net> writes:

Sorry, I am not sure I understand. I thought document.write simply
wrote
the line into the document. When was the document closed?

The document was closed when it finished loading, i.e., *just* before
the document's onload event happens.

While loading the page, the page is processed from top to bottom. A
script is executed when this process reaches it, and a document.write
inserts content between the script that calls it and the remaining,
unprocessed, code.

When processing reaches the end of the document, it is finished. This
closes the document and then calls the onload handler. That means that
document.write's in the onload handler will reopen, and thereby clear,
the document.

/L
--
Lasse Reichstein Nielsen - lrn (AT) hotpop (DOT) com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html
'Faith without judgement merely degrades the spirit divine.'



Reply With Quote
  #5  
Old   
Shock
 
Posts: n/a

Default Re: Onclick problem - 10-16-2003 , 05:50 PM



Ok, I got it.. I just put a direct call in for the first function after I
defined my global variables and arrays. It works and I understand it better
now...I had just never put a direct call in the script like
that...duh..hehe..
.. Thanks everybody for the help!

Shock

"Lasse Reichstein Nielsen" <lrn (AT) hotpop (DOT) com> wrote

Quote:
"Shock" <shock56 (AT) charter (DOT) net> writes:

Sorry, I am not sure I understand. I thought document.write simply
wrote
the line into the document. When was the document closed?

The document was closed when it finished loading, i.e., *just* before
the document's onload event happens.

While loading the page, the page is processed from top to bottom. A
script is executed when this process reaches it, and a document.write
inserts content between the script that calls it and the remaining,
unprocessed, code.

When processing reaches the end of the document, it is finished. This
closes the document and then calls the onload handler. That means that
document.write's in the onload handler will reopen, and thereby clear,
the document.

/L
--
Lasse Reichstein Nielsen - lrn (AT) hotpop (DOT) com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html
'Faith without judgement merely degrades the spirit divine.'



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.