Solved

assigned onload event outside of body tag - not working

Posted on 2003-11-19
7
1,735 Views
Last Modified: 2009-07-29
i have this

document.onload=resizeToContent;


but the function is not called, the call cannot be in the body tage as the page is generated dynamically and the function is only there under specific conditions so i added the above line within the conditiona statements, the function and the call line appear on the page but the function is not called
0
Comment
Question by:James Rodgers
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 17

Accepted Solution

by:
dorward earned 75 total points
ID: 9779188
window.onload = function() {
  resizeToContent; /* Should that be resizeToContent(); ? */
}

Or perhaps you have Mozilla and have turned on the browser's ability to block such irritating scripts (i.e. the resizing of windows - I'm quite capable of making the window the size that I want).
0
 
LVL 11

Expert Comment

by:Zontar
ID: 9779223
window.onload = function() {  resizeToContent(); };

is the correct syntax. However, it's not necessary to use an anonymous function in this case, as

  window.onload = resizeTo Content;

would also be correct.

Your problem is that there is no such thing as a document.onload event, it's window.onload.
0
 
LVL 25

Author Comment

by:James Rodgers
ID: 9779251
used your suggestion and changed it to this

window.onload=resizeToContent;

and worked fine, thanks!

>>...such irritating scripts (i.e. the resizing of windows ...

i'm not resizing the window but a table that exceeds the page length.

its a dynamically generated table with a minimum of 50 rows and a 'header' section that is created based on user input so the header can be very long! so as per clients specs the table was not to exceed the page length so i have it in a scollable div that resizes based on the window size and header size
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 25

Author Comment

by:James Rodgers
ID: 9779293
sorry Zontar, i used the code provided by dorward, it led me to the solution you posted
0
 
LVL 11

Expert Comment

by:Zontar
ID: 9779456
dorward's solution was not correct and mine was, so you awarded the question to him? Whatever...
0
 
LVL 25

Author Comment

by:James Rodgers
ID: 9779537
>>dorward's solution was not correct and mine was, so you awarded the question to him? Whatever...

awarding of the points was based upon the fact that dorward provided me with an answer from which i was able to extract the right answer, that was why i posted the apology...so you would understand why i had chosen dorwards answer instead of yours...

your answer was right, but i had already achieved the answer by using dorwards input so i thought s/he should get the points

from the EE FAQ
http://www.experts-exchange.com/help/qnaFAQ.jsp#3
It is the Asker's right -- and responsibility -- to decide which comments best resolve his problem.
0
 

Expert Comment

by:edwinlamvancouver
ID: 10604639
For all:

This maybe slightly off-subject but just to share this which took me hours to figure out. My experience: be cautious of having more than one window.onload functions for the same window, even in two or more separate physical htm/php files (especially in two or more files.) Only one of them may fire.

Hope that helps somebody.

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to make google charts responsive 4 49
Making Table Thru ASP Response.write 5 19
DataTable column sorting incorrectly 2 18
Boolean 13 20
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question