471,592 Members | 1,149 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,592 software developers and data experts.

Calling External Javascript

Hello all

I have 3 functions in a javacrip file (MyScript.js), which is added to an
ASP.NET 2.0 project

1) no right-click
2) no select text (copy...)
3) History.Back()'

How do I call those 3 functions in all of my pages?

TIA

Newbie Coder
Nov 23 '06 #1
5 3138
Hi,

Newbie Coder wrote:
Hello all

I have 3 functions in a javacrip file (MyScript.js), which is added to an
ASP.NET 2.0 project
To include an external script file in your ASPX page, use

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

Then you can use your functions as if they were included in the page itself.

1) no right-click
2) no select text (copy...)
3) History.Back()'
Are you aware, though, that any effort to prevent right click or to
prevent selecting text, or to control the user's navigation are doomed
to fail and to make you look like a JavaScript fool? :-)

You cannot prevent the user to look at your source code, or to copy text
or images. It's simply impossible. What you put on the web is for
everyone to see, and to use.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Nov 24 '06 #2
Thank you for your reply, but I have tried that method & its not working for
me

I get errors on page

One function I am using I need to run onLoad

How can I achieve this?
"Laurent Bugnion" <ga*********@bluewin.chwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Hi,

Newbie Coder wrote:
Hello all

I have 3 functions in a javacrip file (MyScript.js), which is added to
an
ASP.NET 2.0 project

To include an external script file in your ASPX page, use

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

Then you can use your functions as if they were included in the page
itself.
>
1) no right-click
2) no select text (copy...)
3) History.Back()'

Are you aware, though, that any effort to prevent right click or to
prevent selecting text, or to control the user's navigation are doomed
to fail and to make you look like a JavaScript fool? :-)

You cannot prevent the user to look at your source code, or to copy text
or images. It's simply impossible. What you put on the web is for
everyone to see, and to use.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch

Nov 24 '06 #3
"Newbie Coder" <ne**********@pleasespamme.comwrote in message
news:Od****************@TK2MSFTNGP06.phx.gbl...
Thank you for your reply, but I have tried that method & its not working
for
me

I get errors on page
IF YOU DON'T SAY WHAT ERRORS YOU ARE GETTING, HOW DO YOU EXPECT ANYONE TO
HELP YOU???
I also wrote some JavaScript this morning but it's not working - I'm getting
errors on the page - can you fix it, please...?
Nov 24 '06 #4
Mark

You have an attitude problem I think. I saw this in another post in this
forum

Errors:

Sometimes I get:

Line 20 = <script>
Char 5 = P (see above)
Error: Object Expected
Code: 0
URL: [The page calling the external code]

Line 39 = <TR>
Char 1 = <
Error: Syntax Error
Code: 0
URL: [The page calling the external code]

Line defining Javascript file:

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

MyFunctionNameHere();

</script>


"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:Oo**************@TK2MSFTNGP04.phx.gbl...
"Newbie Coder" <ne**********@pleasespamme.comwrote in message
news:Od****************@TK2MSFTNGP06.phx.gbl...
Thank you for your reply, but I have tried that method & its not working
for
me

I get errors on page

IF YOU DON'T SAY WHAT ERRORS YOU ARE GETTING, HOW DO YOU EXPECT ANYONE TO
HELP YOU???
I also wrote some JavaScript this morning but it's not working - I'm
getting
errors on the page - can you fix it, please...?


Nov 24 '06 #5
"Newbie Coder" <ne**********@pleasespamme.comwrote in message
news:ua**************@TK2MSFTNGP02.phx.gbl...
You have an attitude problem I think.
Yeah, that must be what it is...
I saw this in another post in this forum
More than one, surely... :-)
Errors:

Sometimes I get:

Line 20 = <script>
Char 5 = P (see above)
Error: Object Expected
Code: 0
URL: [The page calling the external code]

Line 39 = <TR>
Char 1 = <
Error: Syntax Error
Code: 0
URL: [The page calling the external code]

Line defining Javascript file:

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

MyFunctionNameHere();

</script>
There you go! If you'd posted the above in the first place we wouldn't be
having this conversation because I can now see exactly what the problem is
and, more importantly, how to fix it.
Nov 24 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Smoke | last post: by
1 post views Thread by Ian Sedwell | last post: by
2 posts views Thread by korund | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.