Using the .NET Windows Forms WebBrowser
control to show the preview of a page, I'm using the following approach described in this SO posting to disable all links on the page:
$(function() {
$('a').click(function() {
$(this).attr('href', 'javascript:void(0);');
});
});
Since the HTML page I want to show as the preview also contains HTML forms, I'm looking for a similar approach to disable all form submit functionality.
I've tried:
$(function() {
$('form').attr('onsubmit', 'return false');
});
But it seems that this doesn't work (read: "still loads the page") for a form like:
<form id="myform" name="myform" onsubmit="return search()" action="">
which I have on the page.
So my question is:
What is the best way to disable all form submit functionality on a HTML page, no matter whether it is a GET or a POST form?
Use this: