views:

163

answers:

4

Hi! I've been trying to find out what's going on with my page for more than an hour.. What I'm trying to do here is to call a javascript function when the page loads, but for some reason it says "object required" then its pointing to my onload event in the body tag. This is what I have..

<head id="Head1" runat="server"> 
    <!-- JAVASCRIPT -->
    <script src="JScript/jquery-1.2.6.pack.js" language="javascript" type="text/javascript"></script>
    <script src="JScript/stepcarousel.js" language="javascript" type="text/javascript"></script>  
    <script src="JScript/Carousel.js" language="javascript" type="text/javascript"></script>
    <script src="JScript/TopNav.js" language="javascript" type="text/javascript"></script>  

<!-- CSS -->
<link href="Style/audiorage.css" rel="stylesheet" type="text/css" />
<link href="Style/carousel.css" rel="stylesheet" type="text/css" />
<link href="Style/tabs.css" rel="stylesheet" type="text/css" />

<title>Audio Rage - Home</title>
</head> 

<body onload="javascript:TopNavPageInitialize();">      
<form id="form1" runat="server">   
<!-- HIDDENFIELDS & SCRIPTS -->
    <input type="hidden" value="Main Navigation" id="hdnTabActiveOnLoad" />

and I have this files in this structure

localhost/mytest/JScript/jquery-1.2.6.pack.js
localhost/mytest/JScript/stepcarousel.js
localhost/mytest/JScript/Carousel.js
localhost/mytest/JScript/TopNav.js
localhost/mytest/mypage.aspx

My TopNav.JS has this function

function TopNavPageInitialize()

I also get "Unexpected call to method or property access." in my carousel but I'm not really worried about it I think if I can fix this maybe that 2nd error that I'm getting can be fixed. Thanks!

I'm confused. What am I missing. Thanks.

A: 

Yep I guess I'll just have to redo it again. Thanks!

+2  A: 

Since you're using jQuery:

$(document).ready(function(){
   // Your code here
 });

use that or

$(window).load(function () {
  // run code
});

that--depending on what you're going for.

Ready just means the dom is ready but images aren't loaded. Load means everything is done loading.

Of course, it sounds like you've got other issues. But this is a much better option than using inline onload events.

rpflo
A: 

like?

$(window).load(function() { alert('x'); });

$(window).load(function funcName() { alert('x'); });

both says object expected

Really, these should be edits to your question - answers are for answers, and often aren't displayed cronologically.Looks to me like your scripts aren't actually loading - if you're getting Object Expected on those calls, then I'd say jQuery isn't running properly.
Zhaph - Ben Duguid
A: 

It looks to me like your scripts aren't loading properly.

To really see what's going on use either Firebug in Firefox, or the developer tools (press F12) in IE8. (If you're still using IE7/6 google IE Developer Toolbar - it will be a start).

Once you're using one of those, you can then see what scripts are being loaded, or whether you're getting 404's or similar for them.

Also, as an aside, you don't need the

language="javascript"

attributes any more.

Zhaph - Ben Duguid