ASP Hosting sale!
Double disk space and transfer for FREE!
Limited time offer! Act Now!

aspdev | articles | tutorials | forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

What is the syntax to inclusde JavaScript file (.js)?

 
Post new topic   Reply to topic    ASPdev.org Forum Index -> JavaScript / DHTML / HTML / CSS
View previous topic :: View next topic  
Author Message
jose



Joined: 14 Dec 2004
Posts: 2

PostPosted: Mon Dec 20, 2004 8:07 am    Post subject: What is the syntax to inclusde JavaScript file (.js)? Reply with quote

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
View user's profile Send private message
administrator
Site Admin


Joined: 01 Oct 2004
Posts: 183

PostPosted: Mon Dec 20, 2004 10:21 am    Post subject: Reply with quote

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
View user's profile Send private message
Kperry



Joined: 16 Feb 2005
Posts: 1

PostPosted: Wed Feb 16, 2005 3:54 pm    Post subject: Javascript syntax Reply with quote

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
View user's profile Send private message
administrator
Site Admin


Joined: 01 Oct 2004
Posts: 183

PostPosted: Wed Feb 16, 2005 5:04 pm    Post subject: Reply with quote

Welcome to our forums Smile

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
View user's profile Send private message
Missie



Joined: 06 Feb 2006
Posts: 25

PostPosted: Wed Feb 08, 2006 7:46 pm    Post subject: Reply with quote

Smile This is really cool codes. I think that I will try them on my site and see what they work like. Smile I think that this forum is really nice and everyone is so nice and helpful. Smile Most forums everyone is rude if you ask one simple question.
Back to top
View user's profile Send private message
newbie



Joined: 01 Oct 2004
Posts: 11

PostPosted: Wed Feb 08, 2006 11:20 pm    Post subject: Reply with quote

What is your site Missie?
_________________
I'm still learning..
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    ASPdev.org Forum Index -> JavaScript / DHTML / HTML / CSS All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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

SQL Tutorial