I’m trying to write a bookmarklet to change the action of all forms on a page to a specified URL, for this example I’m using google.com, and also to add a hidden form element named “action” with the original value.
I’ve got the first part working:
javascript:(function(){var x,i; x = document.forms; for (i = 0; i < x.length; ++i) x[i].action="http://www.google.com/"; })();
But how do I use pure javascript to append the forms’ original action as a new hidden element, like this?
<input type="hidden" name="action" value="http://original-action-url.com" />
if i understand you correctly, This ->
Edit (after your comment) –>
Havent tested it, so might require a bit of tweaking.
Hope that helps.