Steven
Steven

Reputation: 19455

Javascript in ASP.NET is not working

I'm back at coding som .NET stuff and I thought I'd play with Javascripts / jQuery.
I've added my /js/myscript.js file and it loads when the pages has loaded.

In my js file I only have one call alert('TEST').

Why isn't the alert triggered?

I'm on ASP.NET 4.0 - but I don' think that has anything to do with it.
Is there a way to detect if there is any conflict with other scripts?

This goes in the header:

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

After page is loaded, I can use Firebug and exapnd the script and see it's content. So the script is loaded.

Embarrassing update

jQuery(document).ready(function() {
    // Alert if jQuery is loaded
    alert('Test1');
}

alert('Test 2');

As you can see in the above code, I'd forgotten to add the ); and the end of the jQuery(document).ready() function.

After a long day, even the simplest things can go unnoticed.

Upvotes: 0

Views: 86

Answers (2)

Tim B James
Tim B James

Reputation: 20374

Always check for Javascript Errors on something like this. All modern browser have built in HTML/Javascript inspectors which you can use to check for these errors.

Upvotes: 1

Lars Strange
Lars Strange

Reputation: 675

What does your myscript.js look like?

function x(){
  alert('TEST');
}

or just (which will execute on load):

alert('TEST');

Upvotes: 0

Related Questions