Connecting Tech Pros Worldwide Help | Site Map

Using .js files rather than embedded js

Lloyd Sheen
Guest
 
Posts: n/a
#1: Dec 10 '07
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

Larry Bud
Guest
 
Posts: n/a
#2: Dec 10 '07

re: Using .js files rather than embedded js


On Dec 10, 10:13 am, "Lloyd Sheen" <a...@b.cwrote:
Quote:
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?

=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
 
Posts: n/a
#3: Dec 10 '07

re: Using .js files rather than embedded js


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


"Lloyd Sheen" wrote:
Quote:
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
>
>
Lloyd Sheen
Guest
 
Posts: n/a
#4: Dec 10 '07

re: Using .js files rather than embedded js



"Peter Bromberg [C# MVP]" <pbromberg@yahoo.NoSpamMaam.comwrote in message
news:BAE03523-6D59-4800-9E3F-D870A520D45A@microsoft.com...
Quote:
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
>
>
"Lloyd Sheen" wrote:
>
Quote:
>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
>>
>>
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

Mark Rae [MVP]
Guest
 
Posts: n/a
#5: Dec 10 '07

re: Using .js files rather than embedded js


"Lloyd Sheen" <a@b.cwrote in message
news:OedwYO0OIHA.1212@TK2MSFTNGP05.phx.gbl...
Quote:
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 <scripttags...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Lloyd Sheen
Guest
 
Posts: n/a
#6: Dec 10 '07

re: Using .js files rather than embedded js



"Mark Rae [MVP]" <mark@markNOSPAMrae.netwrote in message
news:ugSoWi0OIHA.5264@TK2MSFTNGP02.phx.gbl...
Quote:
"Lloyd Sheen" <a@b.cwrote in message
news:OedwYO0OIHA.1212@TK2MSFTNGP05.phx.gbl...
>
Quote:
>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 <scripttags...
>
>
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
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

Mark Rae [MVP]
Guest
 
Posts: n/a
#7: Dec 10 '07

re: Using .js files rather than embedded js


"Lloyd Sheen" <a@b.cwrote in message
news:ueU1Qx0OIHA.2308@TK2MSFTNGP05.phx.gbl...
Quote:
Thanks Marc,
You're welcome Lloyt.
Quote:
It was an script tag in the file.
I had a feeling it might be... :-)


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Closed Thread


Similar ASP.NET bytes