Javascript includes not recognised

M

Martin Walke

Hi,

This may seem like a client side problem but....

I have web pages that are made up of a number of javascript include files as
well as 'in page' script. They all work fine running locally until I hosted
them on our IIS server. Then the pages refuse to see nested javascript
calls.

e.g.

Main page contains JS code to call a function to one of the include files (-
no probs), which in turn wants to call a function in one of the other JS
include files but falls over with 'object expected' error in the line of
that call - I assume because it can't fine the function.

I think it may be something to do with processing order but as these files
are almost identical to another site that I created (certainly the JS
include files are and that worked 100%), I'm a bit lost. Any help would be
greatly appreciated.

Martin
 
K

Ken Schaefer

The problem may be caused because the browser has managed to download all
included the .js files yet. Instead, it is attempting to call a function in
a file that it doesn't have yet, generating an error.

Cheers
Ken


: Hi,
:
: This may seem like a client side problem but....
:
: I have web pages that are made up of a number of javascript include files
as
: well as 'in page' script. They all work fine running locally until I
hosted
: them on our IIS server. Then the pages refuse to see nested javascript
: calls.
:
: e.g.
:
: Main page contains JS code to call a function to one of the include files
(-
: no probs), which in turn wants to call a function in one of the other JS
: include files but falls over with 'object expected' error in the line of
: that call - I assume because it can't fine the function.
:
: I think it may be something to do with processing order but as these files
: are almost identical to another site that I created (certainly the JS
: include files are and that worked 100%), I'm a bit lost. Any help would be
: greatly appreciated.
:
: Martin
:
:
:
 
C

Chris Barber

Object expected implies that the reference you used is either correct and
the object doesn't exist (script may have failed to load) or that the
reference is incorrect (eg. case sensitivity).

Try putting an alert into the script onload event to see if this pops up
before an alert at the point at which you call the function. You can also
use the DOM to check the script load status if you give the script an id
that you can refer to.

Make sure you .js files are referenced in the HEAD section of the html - the
page body shouldn't load until all elements of this section have loaded
*unless* you specify that a script can be loaded asynchronously.

Chris.


Hi,

This may seem like a client side problem but....

I have web pages that are made up of a number of javascript include files as
well as 'in page' script. They all work fine running locally until I hosted
them on our IIS server. Then the pages refuse to see nested javascript
calls.

e.g.

Main page contains JS code to call a function to one of the include files (-
no probs), which in turn wants to call a function in one of the other JS
include files but falls over with 'object expected' error in the line of
that call - I assume because it can't fine the function.

I think it may be something to do with processing order but as these files
are almost identical to another site that I created (certainly the JS
include files are and that worked 100%), I'm a bit lost. Any help would be
greatly appreciated.

Martin
 
E

Evertjan.

Chris Barber wrote on 17 feb 2004 in
microsoft.public.inetserver.asp.general:
Make sure you .js files are referenced in the HEAD section of the html
- the page body shouldn't load until all elements of this section have
loaded *unless* you specify that a script can be loaded
asynchronously.

Or you can ask serverside help.

replace:

<script type="text/javascript"
src ="/js/myjavascript.js">
</script>


with:

<script type="text/javascript">
<!--#include virtual ="/js/myjavascript.js"-->
</script>
 
K

Ken Schaefer

But that prevents the browser from caching the page since you are using
inline javascript.

The whole point of <script src="/somewhereElse/something.js"
type="text/javascript"> is to allow the browser to cache the .js files
reducing the apparent response time of the application.

Cheers
Ken



: Chris Barber wrote on 17 feb 2004 in
: microsoft.public.inetserver.asp.general:
:
: > Make sure you .js files are referenced in the HEAD section of the html
: > - the page body shouldn't load until all elements of this section have
: > loaded *unless* you specify that a script can be loaded
: > asynchronously.
: >
:
: Or you can ask serverside help.
:
: replace:
:
: <script type="text/javascript"
: src ="/js/myjavascript.js">
: </script>
:
:
: with:
:
: <script type="text/javascript">
: <!--#include virtual ="/js/myjavascript.js"-->
: </script>
:
:
: --
: Evertjan.
: The Netherlands.
: (Please change the x'es to dots in my emailaddress)
 
M

MMitchell

I am having the exact same problem. Brand New win2k install service pack 4 and patches.
The site works on all other servers, but on the new one the javascript includes are not functioning

I put alerts in the included files that never fire.

I tried the virtual includes and I am still getting the problem

Thank


----- Ken Schaefer wrote: ----

But that prevents the browser from caching the page since you are usin
inline javascript

The whole point of <script src="/somewhereElse/something.js
type="text/javascript"> is to allow the browser to cache the .js file
reducing the apparent response time of the application

Cheer
Ke



: Chris Barber wrote on 17 feb 2004 i
: microsoft.public.inetserver.asp.general

: > Make sure you .js files are referenced in the HEAD section of the htm
: > - the page body shouldn't load until all elements of this section hav
: > loaded *unless* you specify that a script can be loade
: > asynchronously
:

: Or you can ask serverside help

: replace

: <script type="text/javascript
: src ="/js/myjavascript.js"
: </script


: with

: <script type="text/javascript"
: <!--#include virtual ="/js/myjavascript.js"--
: </script


: --
: Evertjan
: The Netherlands
: (Please change the x'es to dots in my emailaddress
 
E

Evertjan.

Ken Schaefer wrote on 17 feb 2004 in
microsoft.public.inetserver.asp.general:
The whole point of <script src="/somewhereElse/something.js"
type="text/javascript"> is to allow the browser to cache the .js files
reducing the apparent response time of the application.

I don't think that is that important any more even with POTS bandwith.

A small jpeg is much bigger than the general .js file.

No, IMHO, the point is to make one .js file usable
in many different .html's.

And the serverside include is not possible
for many clientside only virtual servers.

And some people think it diminishes the visual exposure
to simpleminded view-sorcerers.
 
M

MMitchell

More Info: When I do the virtual the alerts fire but the popup menu wont function
The application is a .net 1.0 app using user controls for the header.

I have tried if from IE and Safari and both work on all other machines except this one

Thank
 
E

Evertjan.

=?Utf-8?B?TU1pdGNoZWxs?= wrote on 17 feb 2004 in
microsoft.public.inetserver.asp.general:
More Info: When I do the virtual the alerts fire but the popup menu
wont function. The application is a .net 1.0 app using user controls
for the header.

So you are heavily OT here on this classical ASP NG.

Please see a dotnet group.
 
M

Martin Walke

Thanks guys.

All my includes are in the head section, and the offending line is being
called from the page onLoad routine which I thought was only actioned once
the page HAD downloaded all its 'bits'. It doesn't do it when using PWS, so
at least I can carry on testing for the moment but it must be something it
the timing og page downloads.

I'll check out the DOM object to see how I can check the script loading -
any idea of the method?

In terms of sequence of events when the browser loads a page, is there some
info somewhere that explains it? I've browsed the web without much luck but
sometimes it's useful to know what keywords to look for ;-)!

Thanks again
Martin
 
M

Martin Walke

<<....is to allow the browser to cache the .js files>>
And for us, in this application, that is important.

Martin
 
E

Evertjan.

=?Utf-8?B?bW1pdGNoZWxs?= wrote on 17 feb 2004 in
microsoft.public.inetserver.asp.general:
Isn't this the IIS General Newsgroup?

No.

I suppose that is:

<microsoft.public.inetserver.iis>
 
B

Bob Barrows [MVP]

mmitchell said:
Isn't this the IIS General Newsgroup?

No. this is the inetserver.ASP.general group.

There are a whole bunch of newsgroups devoted to .Net questions. They all
have the word "dotnet" in their names. E.G.,

microsoft.public.dotnet.framework.aspnet
etc.

HTH,
Bob Barrows
 
C

Chris Barber

Use body_onload event - the page onload fires as soon as the page HTML has
loaded (irrespective of external dependencies).

Chris.

Thanks guys.

All my includes are in the head section, and the offending line is being
called from the page onLoad routine which I thought was only actioned once
the page HAD downloaded all its 'bits'. It doesn't do it when using PWS, so
at least I can carry on testing for the moment but it must be something it
the timing og page downloads.

I'll check out the DOM object to see how I can check the script loading -
any idea of the method?

In terms of sequence of events when the browser loads a page, is there some
info somewhere that explains it? I've browsed the web without much luck but
sometimes it's useful to know what keywords to look for ;-)!

Thanks again
Martin
 
C

Chris Barber

and ...

what the heck is everyone else blithering on about trying to argue about
client side <script src=""></script> usage - it's one of the cornerstones of
HTML and I for one use it all the time since even a few small scripts can
amount to 5-10 seconds delay in page load when not cached. Server-side
includes belong in server-side code *not* client side HTML.

So ... Martin, keep with what you have - it is correct - it's obvious that
its only the calling convention and timing to your included script functions
that is awry. As a benchmark, I have one heavily interactive web app with 15
include files totally 200k of javascript between them and not once has a
body_onload call to one of the functions failed.

Chris.


Thanks guys.

All my includes are in the head section, and the offending line is being
called from the page onLoad routine which I thought was only actioned once
the page HAD downloaded all its 'bits'. It doesn't do it when using PWS, so
at least I can carry on testing for the moment but it must be something it
the timing og page downloads.

I'll check out the DOM object to see how I can check the script loading -
any idea of the method?

In terms of sequence of events when the browser loads a page, is there some
info somewhere that explains it? I've browsed the web without much luck but
sometimes it's useful to know what keywords to look for ;-)!

Thanks again
Martin
 
M

Martin Walke

Aha! Thanks Chris.

Martin

Chris Barber said:
Use body_onload event - the page onload fires as soon as the page HTML has
loaded (irrespective of external dependencies).

Chris.

Thanks guys.

All my includes are in the head section, and the offending line is being
called from the page onLoad routine which I thought was only actioned once
the page HAD downloaded all its 'bits'. It doesn't do it when using PWS, so
at least I can carry on testing for the moment but it must be something it
the timing og page downloads.

I'll check out the DOM object to see how I can check the script loading -
any idea of the method?

In terms of sequence of events when the browser loads a page, is there some
info somewhere that explains it? I've browsed the web without much luck but
sometimes it's useful to know what keywords to look for ;-)!

Thanks again
Martin

files files
 
M

MMitchell

I got here by microsoft.public.inetserver.iis and found this from Martin's orignal post.
 
C

Chris Barber

Probably didn't see it on PWS because the load times would have been quick
enough for the function to be available (caching helps as well).

Chris.

Aha! Thanks Chris.

Martin
 
B

Bob Barrows [MVP]

MMitchell said:
I got here by microsoft.public.inetserver.iis and found this from
Martin's orignal post.

I'm not sure why you think that is relevant. You have a question about a
dotnet application. While you may be lucky enough to find somebody here who
can answer a question about a dotnet application, you can eliminate the luck
factor by posting to the dotnet newsgroups where the dotnet gurus can be
found.

Please do not interpret this as a reprimand: we are simply trying to help
you maximize your chances of getting a relevant reply.

Bob Barrows
 
M

MMitchell

Its an IIS problem, not a .net problem
From browsing alot of the newsgroups, Thier is something going on
with server includes.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top