0

I would like to add a small bit of javascript to an existing Asp.Net MVC application. I have not been able to get the javascript to work, and so I tried creating a simple page to showcase the problem.

The code works when you just open it in a browser, however if the webpage provided by my application it does not work - the onsubmit function is never called.

The actual source code is identical in both situation, the only difference is in the success case I open the html file directly. In the failure case it is returned by my app.

I think there must be some kind of communication between the web app and the browser that disables javascript, but I don't know what it would be.

<!doctype html>
<html>
<head>
	<title></title>
</head>
<body>

<script>
    function dontSubmit() {
	alert("You pressed submit");
	return false;
}
</script>

<form action="http://www.google.com/" method="POST" onsubmit="return dontSubmit();">
	<input type="submit" value="Submit">
</form>

</body>
</html>

4
  • Show us the view that generates this page Commented May 9, 2017 at 19:17
  • Did you try any of these stackoverflow.com/questions/1079479/… Commented May 9, 2017 at 19:33
  • can you please sow a sample of your _Laout.cshtml page? Commented May 10, 2017 at 5:13
  • did you try run debug mode in your browser with developer console(f12)? Commented May 10, 2017 at 6:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.