View previous topic :: View next topic |
Author |
Message |
jose
Joined: 14 Dec 2004 Posts: 2
|
Posted: Mon Dec 20, 2004 8:07 am Post subject: What is the syntax to inclusde JavaScript file (.js)? |
|
|
What is the syntax to inclusde JavaScript file (.js) into a web page. I have written more than 20 JavaScript functions and I don't want them to be visible when somebosy click view source on my web pages.
Jose |
|
Back to top |
|
|
administrator Site Admin
Joined: 01 Oct 2004 Posts: 183
|
Posted: Mon Dec 20, 2004 10:21 am Post subject: |
|
|
Hi Jose,
Here is the JavaScript external file include syntax:
<script language="JavaScript" src="ExternalJavaScript.js"></script>
Cheers _________________ Peter
ASP & ASP.NET Articles and Tutorials |
|
Back to top |
|
|
Kperry
Joined: 16 Feb 2005 Posts: 1
|
Posted: Wed Feb 16, 2005 3:54 pm Post subject: Javascript syntax |
|
|
I'm really new to integrating javascript with asp.net so I'm hoping you can help me. I have an external javascript file (myfile.js), which I have referenced using the tags in the previous post. I'm confused though on how to call the javascript file when my specific button is clicked. For example, when btnHello is clicked, it needs to go run the javascript contained in myfile.js. Do I add the call in the code behind page to the button's click event? Or do I add it in the html code for that button? What is the syntax? Thanks! |
|
Back to top |
|
|
administrator Site Admin
Joined: 01 Oct 2004 Posts: 183
|
Posted: Wed Feb 16, 2005 5:04 pm Post subject: |
|
|
Welcome to our forums
The best thing to do is to put all your javascript code which is in your myfile.js in a javascript function there. Then just call that function from the onClick event handler for the button:
Code: |
---- myfile.js -----
function DoSomething(){
// Your JS code goes here
}
|
Code: |
---- ASP.NET page ----
....
....
.... onClick="DoSomething();"....
....
|
Cheers, _________________ Peter
ASP & ASP.NET Articles and Tutorials |
|
Back to top |
|
|
Missie
Joined: 06 Feb 2006 Posts: 25
|
Posted: Wed Feb 08, 2006 7:46 pm Post subject: |
|
|
This is really cool codes. I think that I will try them on my site and see what they work like. I think that this forum is really nice and everyone is so nice and helpful. Most forums everyone is rude if you ask one simple question. |
|
Back to top |
|
|
newbie
Joined: 01 Oct 2004 Posts: 11
|
Posted: Wed Feb 08, 2006 11:20 pm Post subject: |
|
|
What is your site Missie? _________________ I'm still learning.. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2002 phpBB Group
|