Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-29-2010, 05:41 AM   PM User | #1
ssheng
New to the CF scene

 
Join Date: Jul 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
ssheng is an unknown quantity at this point
window.onload doesn't work in IE, but works on FF

I met a confusion about window.onload()

in my index page, here is the code:
<script language = "JavaScript">
$(document).ready(function(){
Main.loadHome();
}
});
</script>

<body>
......
<div id="main"></div>
.......
</body>

js file:

Main = function()
{}
Main.loadHome = function()
{
$('#main').load("homepage.php");
}

homepage.php

<script language="JavaScript" type="text/javascript">
window.onload=function(){
....................
}
</script>

Here is the problem
it works in FF, but seems window.onload didn't call in IE, which makes me confused.

Last edited by ssheng; 07-29-2010 at 09:22 AM..
ssheng is offline   Reply With Quote
Old 07-29-2010, 09:13 AM   PM User | #2
ssheng
New to the CF scene

 
Join Date: Jul 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
ssheng is an unknown quantity at this point
anyone help me?
ssheng is offline   Reply With Quote
Old 07-29-2010, 10:13 AM   PM User | #3
santhoshj400
Banned

 
Join Date: Jul 2010
Posts: 66
Thanks: 0
Thanked 1 Time in 1 Post
santhoshj400 is an unknown quantity at this point
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Busted!</title>
<meta name="author" content="Dean Edwards"/>
<!-- keeping code tidy!! -->
<meta name="copyright" content="&copy; copyright 2005, Dean Edwards"/>
<style>
#message {
background-color: red;
color: white;
font-weight: bold;
font-size: 2em;
text-align: center;
}
</style>
<script type="text/javascript">
function init() {
// quit if this function has already been called
if (arguments.callee.done) return;

// flag this function so we don't do the same thing twice
arguments.callee.done = true;

// create the "page loaded" message
var text = document.createTextNode("Page loaded!");
var message = document.getElementById("message");
message.appendChild(text);
};

/* for Mozilla */
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", init, false);
}

/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
document.write("<script defer src=ie_onload.js><"+"/script>");
/*@end @*/

/* for other browsers */
window.onload = init;
</script>

</head>
<body>
<h1>Busted!</h1>
<p id="message"></p>
<script type="text/javascript">
// create a unique image source so that this page works with continued testing
var src = "http://www.nasa.gov/images/content/84857main_EC04-0325-23_lg.jpg?" + Number(new Date);
document.write("<img src=" + src + " height=240 width=300>");
</script>
</body>
</html>

This works fine in all the browsers
Thanks & Regards
santhoshj400 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

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

Forum Jump


All times are GMT +1. The time now is 09:14 PM.


Advertisement
Log in to turn off these ads.