Just a little thing I've always wondered:
Is it possible to submit a form on any webpage, rather than clicking the forms submit button, I want to do it from the chrome console (ctrl+shift+j in chrome)?
I've tried a couple ways but I either get an error like
Cannot use function submit on undefined
or
HTML tag has not function submit.
Any help?
PS - If you go here and try and submit the form on your right through the console click here
Just a little thing I've always wondered:
Is it possible to submit a form on any webpage, rather than clicking the forms submit button, I want to do it from the chrome console (ctrl+shift+j in chrome)?
I've tried a couple ways but I either get an error like
Cannot use function submit on undefined
or
HTML tag has not function submit.
Any help?
PS - If you go here and try and submit the form on your right through the console click here
Share Improve this question asked Sep 29, 2012 at 12:41 user818700user818700 1- What have you entered in the console? On which page did you do that? – Bergi Commented Sep 29, 2012 at 13:23
3 Answers
Reset to default 12form = document.getElementById("frm1")
form.submit()
works on your example when viewing the standalone iframe.
For your example when working with an iframe:
// from http://stackoverflow.com/questions/1452871/how-can-i-access-iframe-elements-with-javascript
function iframeRef( frameRef ) {
return frameRef.contentWindow ? frameRef.contentWindow.document : frameRef.contentDocument
}
var inside = iframeRef( document.getElementsByTagName('iframe')[0] );
// from @DeanGrobier
form = inside.getElementById("frm1")
form.submit()
It is inside an iframe in your example. In your case, you must enter this in the console for it to work:
var q = window.document.getElementsByTagName('iframe')[1];
var r = q.contentWindow.document.getElementById("frm1");
r.submit();
or, in just one line:
window.document.getElementsByTagName('iframe')[1].contentWindow.document.getElementById("frm1").submit();