How to include a js file globally in asp.net

  • Thread starter Thread starter green_tea
  • Start date Start date
G

green_tea

Hi there,


I'd like to know how to include a js file globally in asp.net so all my
pages can access js functions in this file. (Only include it once and
not include
this file one by one to all my pages.)

Thanks for your help.

Green
 
Hello there,

If you're using .NET 2.0, you can include the js file in a master page.
If using 1.x, you will have to include it in each page via the <script
language='javascript' src="myjs.js"></script> tagging.

Alternatively, you can place the entire site as the src of a
single-framed frameset, and include the script tags in the frameset
page; then, when you call your js methods, always call
top.methodname(), since the frameset page is the top.
 
Thanks a lot KJ.

I guess I am going to include it in the frameset as I am use frames.

Thanks for you help.

Green.
 
Hi,

Thanks a lot KJ.

I guess I am going to include it in the frameset as I am use frames.

Thanks for you help.

Green.

Including a script file in the frameset is often a bad idea. Remember
that each frame and the frameset itself are separate windows, so if the
script runs in the frameset, you must use inter-window communication,
which complicates the whole process.

In the contrary, masterpages and their content run, eventually, in one
single window, so you won't have that issue.

HTH,
Laurent
 
I guess I am going to include it in the frameset as I am use frames.

I concur with what Laurent said, and really advise you not to do that.

Use MasterPages instead.
 
Thanks Mark and Laurent and everyone who helped me.

I am new to ASP.NET, it seems I have a lot to learn.

Green.
 
Back
Top