I realize this isn’t terrific from a security perspective but humor me.
Is there a way to create a bookmarklet that submits a form, such as a login form. For example, this works, but only if there is a page loaded in the current browser window:
javascript:(function(){document.body.innerHTML += '<form id=f action=https://www.mysite.com/login method=post><input type=hidden name=un value=uname><input type=hidden name=pw value=pword>';document.getElementById("f").submit();})();
Is there some way to construct the form right in the JavaScript and submit that?
If you don’t need the current page at all, you can completely replace it by having the bookmarklet expression return a string containing the complete new page:
then you don’t have to worry about whether the previous page had a
<body>or another element withid="f".(And +1 Matti:
innerHTML+=is always a mistake.)