Go Back   Dynamic Drive Forums > DD Scripts > Dynamic Drive scripts help
Search Dynamic Drive Forums:

Reply
 
Thread Tools Search this Thread
  #1  
Old 10-21-2004, 09:16 PM
Heero Heero is offline
New Comer (less than 5 posts)
 
Join Date: Oct 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Unable to call external script

I am using the calender javascript found at: http://www.dynamicdrive.com/dynamicindex6/clock3.htm

The script requires me to include <body onLoad="goforit()">. The script runs fine if the script is inside of the actual file; however, when I put the script in an external file, the script fails to run and I get the error

"Object expected" at the <body onLoad="goforit()"> line.

I'm thinking this has to do with the fact the body can't find the goforit() function because it is in an external file. What would be the best solution to this problem other than including the script inside the file itself?
Reply With Quote
  #2  
Old 10-22-2004, 06:40 AM
cr3ative's Avatar
cr3ative cr3ative is offline
Elite Coders
 
Join Date: Aug 2004
Location: Brighton
Posts: 1,564
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Makesure that the body onload tag is placed AFTER the external script is called.

cr3ative
__________________
Mostly retired member, PM me if you have a specific query to make sure I recieve it :)
cr3ation | cr3ation hosting | cr3ation web design | read the stickies
Reply With Quote
  #3  
Old 10-23-2004, 05:54 PM
Heero Heero is offline
New Comer (less than 5 posts)
 
Join Date: Oct 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by cr3ative
Makesure that the body onload tag is placed AFTER the external script is called.

cr3ative
It doesn't work, unless I am misconceiving what you mean by placing the body onload tage after the external script. The external script is inside the body tag itself. The only position I can place the gofotit() function is at the beginning of the body tag itself.
Reply With Quote
  #4  
Old 10-23-2004, 05:59 PM
cr3ative's Avatar
cr3ative cr3ative is offline
Elite Coders
 
Join Date: Aug 2004
Location: Brighton
Posts: 1,564
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Make sure the tags are in this order:

<script src="whatever.js"></script>

<body onload="javascript:goforit();">

and not the other way around.
cr3ative
__________________
Mostly retired member, PM me if you have a specific query to make sure I recieve it :)
cr3ation | cr3ation hosting | cr3ation web design | read the stickies
Reply With Quote
  #5  
Old 10-23-2004, 08:34 PM
Heero Heero is offline
New Comer (less than 5 posts)
 
Join Date: Oct 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You'll have to forgive me. My javascript skills are horrible. This is my code so far:

<html>
<head>
<script type="text/JavaScript" src="Library/Calender.js"></script>
</script>
<title>Untitled Document</title>
</head>
<body onLoad="javascript: goforit()">
</body>
</html>

First, I still get the object expected error at the body onload line. Second, how can I place the calender/time where I want it?

Thanks.
Reply With Quote
  #6  
Old 10-24-2004, 08:27 AM
cr3ative's Avatar
cr3ative cr3ative is offline
Elite Coders
 
Join Date: Aug 2004
Location: Brighton
Posts: 1,564
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Before we go too far, we need to sort out the error

1. Make sure your host is not case-sensitive. If it is, re-enter the .js filename with the capitalization found on the server.

2. Make the address absolute, not relative, so instead of library/calender.js, change this to http://www.yourhost.com/yourpage/library/calender.js

3. Try changing javascript: goforit() with javascript:goforit();

cr3ative
__________________
Mostly retired member, PM me if you have a specific query to make sure I recieve it :)
cr3ation | cr3ation hosting | cr3ation web design | read the stickies
Reply With Quote
  #7  
Old 10-24-2004, 05:12 PM
Heero Heero is offline
New Comer (less than 5 posts)
 
Join Date: Oct 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Smile

Okay, I figured it out. I used the code:

<html>
<head>
<title>Untitled Document</title>
</head>
<body onLoad="goforit()">
<script src="Library\Calender.js">
</script>
<span id="clock"></span>
</body>
</html>

One of the problems was I included the tags <script> and </script> in the actually .js file. So when I ran the file, I had two <script></script> tags. I also included the <span id="clock"></span> part inside of the script itself, which could have resulted in an unknown error. Either way, I finally got the script working.

Thanks for your help cr3ative
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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. The time now is 12:17 AM.

Home - Contact Us - Archives - Link to DD - Top 

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.