O'Reilly logo

Microsoft Visual Studio 2015 Unleashed, Third Edition by Mike Snell, Lars Powers

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Storing and Using Scripts

JavaScript can be embedded directly inside a web page or stored as a separate script file. Before getting started with the language, let’s look at where you can write JavaScript, how you store it, and how you can include it in your pages.

Embed Script on a Page

You can embed JavaScript code directly inside a page. This is true of .html pages and .cshtml views (and other .NET pages). The JavaScript will execute where it is found within the page. Later in this chapter, you will see how you can use events to determine when your JavaScript code should execute.

The JavaScript code placed inside a page should be contained within a <script> tag. The <script> tag looks like this.

<script type="text/javascript"> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required