Here is the situation. I made some test files.
1. Main html file. iload.html <html> <head> <script src="/js/jquery/jquery.js" type="text/javascript"></script> <script>$(function() { $('#div').load('itest.html'); } ); </script> </head> <body> <div id='div'> <p>Loading...</p> </div> </body> </html> 2. Is a child html file. itest.html <html> <head> <script src="itest.js"></script> <script>alert('That\'s inline alert!!!');</script> </head> <body> That's my body, duddies! :-) </body> <script>test();</script> </html> 3. Third, is an javascript file. itest.js function test() { alert('I am test alert!!'); } When we load iload.html into the browser, it successfuly get itest.html within DIV and, then, itest.js as it could be verified on the apache logs: 127.0.0.1 - - [30/Oct/2007:14:10:50 +0200] "GET /tmp/iload.html HTTP/1.1" 200 232 127.0.0.1 - - [30/Oct/2007:14:10:50 +0200] "GET /js/jquery/jquery.js HTTP/1.1" 304 - 127.0.0.1 - - [30/Oct/2007:14:10:50 +0200] "GET /tmp/itest.html HTTP/1.1" 304 - 127.0.0.1 - - [30/Oct/2007:14:10:51 +0200] "GET /tmp/itest.js HTTP/1.1" 304 - 127.0.0.1 - - [30/Oct/2007:15:08:56 +0200] "GET /tmp/iload.html HTTP/1.1" 304 - 127.0.0.1 - - [30/Oct/2007:15:08:56 +0200] "GET /js/jquery/jquery.js HTTP/1.1" 304 - 127.0.0.1 - - [30/Oct/2007:15:08:56 +0200] "GET /tmp/itest.html HTTP/1.1" 304 - 127.0.0.1 - - [30/Oct/2007:15:08:57 +0200] "GET /tmp/itest.js HTTP/1.1" 304 - So. All this looks fine. But javascript code does not work on the itest.html. The first alert 'That\'s inline alert!!!' is displayed fine. After pressing OK on it browser shows an error: test is not defined [Break on this error] eval.call( window, data ); After debugging jquery.js I noticed that eval.call() is executed three times. First, it got as data alert('That\'s inline alert!!!'). Second, it got test(); and generate the error of test not defined Third, it got the contents of itest.html Just in this sequence. As we could see, jquery.js try to execute test() before definition of function test(). So the error is occured. But it seems like incorrect situation. Are there anybody who solve a problem like that? -- View this message in context: http://www.nabble.com/Javascript-does-not-work-on-a-page-loaded-tf4718628s27240.html#a13489213 Sent from the jQuery General Discussion mailing list archive at Nabble.com.