I am trying to embed a form within an iframe that will load on a random page when the user clicks a bookmarklet.
Below is the code snippet I have written so far:
loginForm = document.createElement("form");
loginForm.setAttribute("method","Post");
loginForm.setAttribute("action","http://devserver:8000/action/");
parameters = {};
parameters['url'] = parent.window.location;
for(var key in parameters)
{
var hiddenField = document.createElement("input");
hiddenField.setAttribute('type',"hidden");
hiddenField.setAttribute('name',key);
hiddenField.setAttribute('value',parameters[key]);
loginForm.appendChild(hiddenField);
}
loginIFrame = document.createElement('iframe');
loginIFrame.src = "about:blank";
loginIFrame.appendChild(loginForm);
loginIFrame.style.top = "0px";
loginIFrame.style.position='fixed';
loginIFrame.style.display = 'block';
loginIFrame.style.zIndex = 100;
loginIFrame.style.border = "solid #48D236 10px";
loginIFrame.height = "25px";
loginIFrame.width = "100%";
loginIFrame.style.border = 0;
loginIFrame.id = "loginFrame";
loginIFrame.name = "loginFrame";
usernameField = document.createElement("input");
usernameField.type = "text";
usernameField.size = 8;
usernameField.name = "usernameField";
usernameField.id = "usernameField";
passwordField = document.createElement("input");
passwordField.type = "password";
passwordField.size = 8;
passwordField.name = "passwordField";
passwordField.id = "passwordField";
submitButton.style.position='fixed';
submitButton.style.top = "60px";
submitButton.type = "button";
submitButton.value = "Submit";
submitButton.onclick = function(){loginUser();};*/
b.style.position="relative";
addToBody(loginIFrame);
loginForm.submit();
Problem arises as the entire page reloads upon submission (last line of code) instead of just the iframe. Any suggestions?
Thank you in advance