Using the .NET Windows Forms WebBrowser control to show a preview of the page, I use the following approach described in this post 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, since the preview also contains HTML forms, I am looking for a similar approach to disable all form submission features.
I tried:
$(function() { $('form').attr('onsubmit', 'return false'); });
But it doesn't seem to work (read: "still loading 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 submission features on an HTML page, whether it is a GET or POST form?
javascript jquery forms
Uwe keim
source share