Using .js files rather than embedded js

L

Lloyd Sheen

I am trying to migrate from lots of javascript embedded within an aspx file
to using .js files.

So far no luck. I have created the .js file which contains part of the
javascript which was part of the aspx file and worked correctly.

First it seems that I cannot get what should exist in the .js file. I
assume although finding real examples on the net is more difficult than I
thought. My .js file contains 3 functions. There is no script tag.

I then (although I have tried the RegisterClientScriptBlock method) to
simply put the following into the <head

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

Now when I run I get that wonderful "A Runtime Error has occured. Do you
wish to debug? Line 3 Error Syntax error". Of course what is line 3????

Right now I am stuck.

Thanks
Lloyd Sheen
 
L

Larry Bud

I am trying to migrate from lots of javascript embedded within an aspx file
to using .js files.

So far no luck. I have created the .js file which contains part of the
javascript which was part of the aspx file and worked correctly.

First it seems that I cannot get what should exist in the .js file. I
assume although finding real examples on the net is more difficult than I
thought. My .js file contains 3 functions. There is no script tag.

I then (although I have tried the RegisterClientScriptBlock method) to
simply put the following into the <head

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

Now when I run I get that wonderful "A Runtime Error has occured. Do you
wish to debug? Line 3 Error Syntax error". Of course what is line 3????

Right now I am stuck.

Line 3 is probably in your .js file. Sounds like a syntax error to
me. Perhaps you're missing a paren. Can you post some of your .js
file?
 
L

Lloyd Sheen

Peter Bromberg said:
Line 3 - sounds to me like whatever was on Line 3 of your script.js file.
Did
you remote the "<script>" tags from the file? If it's an include from a
src=
attribute, you don't want them in the actual file.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com

I had 3 functions in one .js file. When I took 2 of them out and put them
back into the aspx file I had no problem.

Is there a way to put more than one function into a .js file. I am doing
this (one to learn) and mostly to make the aspx file more readable.

Thanks
Lloyd Sheen
 
M

Mark Rae [MVP]

I had 3 functions in one .js file. When I took 2 of them out and put them
back into the aspx file I had no problem.

Is there a way to put more than one function into a .js file. I am doing
this (one to learn) and mostly to make the aspx file more readable.


You can have as many as you like...

Just make sure that each is correctly parenthesised e.g.

function firstFunction()
{

}

function secondFunction()
{

}

And remember not to include any <script> tags...
 
L

Lloyd Sheen

Mark Rae said:
You can have as many as you like...

Just make sure that each is correctly parenthesised e.g.

function firstFunction()
{

}

function secondFunction()
{

}

And remember not to include any <script> tags...

Thanks Marc,

It was an script tag in the file. I will attribute this to monday morning.

This make my aspx file much easier to deal with and the javascript most of
which works fine be isolated so that I can find the areas that need changes
much faster.

Lloyd Sheen
 

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,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top