472,958 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 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 3207
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Smoke | last post by:
We had a javascript calling a Cold Fusion page (.cfm) and it was working for 2 years. Suddenly yesterday or today its decided it doesn't want to work anymore. I'm picking up somebody elses code I...
1
by: Ian Sedwell | last post by:
Hi guys Many thanks to all who replied to my original question. Actually, it's dead easy and the way I was doing it was correct the first time. You do indeed simply call the VBScript routine...
11
by: Jake j | last post by:
Yes, this is a simple and straightforward thing to do as long as the .js file doesn't use a function. When I try a script with a function in a js file I can't get it to work (though it works fine...
2
by: korund | last post by:
<html> <head> <title>Demo</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script type="text/javascript"> function init() { alert('Message 1');...
4
by: Adam Smith | last post by:
Hello, How can I call or trigger an external javascript twice in a form? I have <script language="JavaScript" src="country_state.js" name="Country_State"> <script type="text/javascript"...
1
by: msraog | last post by:
Hi, Iam getting an error while calling a function which is declared in the external javascript file jsp file:- ------------------- <SCRIPT language='JavaScript1.1' src='includes/common.js>...
5
by: Shereef | last post by:
Hi All, I need to call an external application from my javascript and that external appn(c or c++) should give an html page back to me and i need to produce that new html page to the user. will...
2
by: Debbie | last post by:
I have always used VBScript but now need to convert my syntax to JavaScript. In an external file, I have a function that is called when a user clicks a button on a login page. The function checks...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

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.