Connecting Tech Pros Worldwide Forums | Help | Site Map

Probably a daft question?

Harry
Guest
 
Posts: n/a
#1: Jul 20 '05
but I'm a bit puzzled with javascript functions you can include to use in a
JSP page - you can't see them in the page source code but can call them -
does this mean

they are called on the server each time - I always thought javascript was
client side only?

or are all of them in the include .js file downloaded for use at the client
end somewhere?

enlighten me someone?

thanks

harry



steve stevo
Guest
 
Posts: n/a
#2: Jul 20 '05

re: Probably a daft question?


Include files are part of the page that is called, if the files are created
for server side use ie asp files etc then they are run on the server and
there is no need for them to be downloaded by the client, however if you
have front end code, ie .js files and have not specified them to run on the
server they will be downloaded with the page. The files will be stored on
the client allowing multiple use and in effect quicker download times long
term.

hope this helps

Simn Christie



"Harry" <a@abc.com> wrote in message
news:PcYbb.3002$qx5.26566684@news-text.cableinet.net...[color=blue]
> but I'm a bit puzzled with javascript functions you can include to use in[/color]
a[color=blue]
> JSP page - you can't see them in the page source code but can call them -
> does this mean
>
> they are called on the server each time - I always thought javascript was
> client side only?
>
> or are all of them in the include .js file downloaded for use at the[/color]
client[color=blue]
> end somewhere?
>
> enlighten me someone?
>
> thanks
>
> harry
>
>[/color]


Tim Slattery
Guest
 
Posts: n/a
#3: Jul 20 '05

re: Probably a daft question?


"Harry" <a@abc.com> wrote:
[color=blue]
>but I'm a bit puzzled with javascript functions you can include to use in a
>JSP page - you can't see them in the page source code but can call them -
>does this mean
>
>they are called on the server each time - I always thought javascript was
>client side only?
>
>or are all of them in the include .js file downloaded for use at the client
>end somewhere?[/color]

If you're talking about this kind of syntax:

<SCRIPT LANGUAGE="Javascript" SRC="something.js">

Then yes, that's handled by the client-side browser. When the browser
encounters this statement, it issues an HTML request for
"something.js", and interprets it just as if its contents were between

<SCRIPT LANGUAGE="Javascript">

and

</SCRIPT>

tags.

Various server-side processing schemes (ASP, PHP, etc) implement
server-side includes. If you use those, the included file is
transmitted to the client as part of the original request, the client
never knows that the content came from a separate file.

--
Tim Slattery
Slattery_T@bls.gov
Harry
Guest
 
Posts: n/a
#4: Jul 20 '05

re: Probably a daft question?


Thanks chaps, makes sense now - just a bit puzzled why when viewing page
source you can't actually see the javascript functions!

"Harry" <a@abc.com> wrote in message
news:PcYbb.3002$qx5.26566684@news-text.cableinet.net...[color=blue]
> but I'm a bit puzzled with javascript functions you can include to use in[/color]
a[color=blue]
> JSP page - you can't see them in the page source code but can call them -
> does this mean
>
> they are called on the server each time - I always thought javascript was
> client side only?
>
> or are all of them in the include .js file downloaded for use at the[/color]
client[color=blue]
> end somewhere?
>
> enlighten me someone?
>
> thanks
>
> harry
>
>[/color]


steve stevo
Guest
 
Posts: n/a
#5: Jul 20 '05

re: Probably a daft question?


The functions are not in the downloaded page but can be references by that
page.

in this way you could have a function

eg
function showAlert(str){
alert(str)
}

and if you wanted to use the function in 2 html pages, then you include the
..js file in both and only need to download it once as it would be cached on
the client machine.

hope this helps

Simon Christie





"Harry" <a@abc.com> wrote in message
news:7xZbb.3062$bm7.28004533@news-text.cableinet.net...[color=blue]
> Thanks chaps, makes sense now - just a bit puzzled why when viewing page
> source you can't actually see the javascript functions!
>
> "Harry" <a@abc.com> wrote in message
> news:PcYbb.3002$qx5.26566684@news-text.cableinet.net...[color=green]
> > but I'm a bit puzzled with javascript functions you can include to use[/color][/color]
in[color=blue]
> a[color=green]
> > JSP page - you can't see them in the page source code but can call[/color][/color]
them -[color=blue][color=green]
> > does this mean
> >
> > they are called on the server each time - I always thought javascript[/color][/color]
was[color=blue][color=green]
> > client side only?
> >
> > or are all of them in the include .js file downloaded for use at the[/color]
> client[color=green]
> > end somewhere?
> >
> > enlighten me someone?
> >
> > thanks
> >
> > harry
> >
> >[/color]
>
>[/color]


Zac Hester
Guest
 
Posts: n/a
#6: Jul 20 '05

re: Probably a daft question?


Harry wrote:
[color=blue]
> Thanks chaps, makes sense now - just a bit puzzled why when viewing page
> source you can't actually see the javascript functions!
>[/color]

You can if you just put the name of their JavaScript file in your
browser's address bar. If you see a line like this:

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

And your browser is looking at:

http://www.example.com/mypage.html

Then, just type this:

http://www.example.com/jscode/page.js

And you will probably be prompted to save the file to your computer (or
it will just display the code). You're just duplicating what the
browser does and saving the results for your viewing enjoyment.

HTH,
Zac


[color=blue]
> "Harry" <a@abc.com> wrote in message
> news:PcYbb.3002$qx5.26566684@news-text.cableinet.net...
>[color=green]
>>but I'm a bit puzzled with javascript functions you can include to use in[/color]
>
> a
>[color=green]
>>JSP page - you can't see them in the page source code but can call them -
>>does this mean
>>
>>they are called on the server each time - I always thought javascript was
>>client side only?
>>
>>or are all of them in the include .js file downloaded for use at the[/color]
>
> client
>[color=green]
>>end somewhere?
>>
>>enlighten me someone?
>>
>>thanks
>>
>>harry
>>
>>[/color]
>
>
>[/color]

Closed Thread