therealwesfoster Posted December 10, 2007 Share Posted December 10, 2007 I'm wanting to be able to run a script that will log me in (to 1 of 2 different sites) automatically. I'm having trouble with this.. I have this: index.htm <html> <head> <title>Test Loginner </title> <script src="ccsh.js"></script> </head> <body> <iframe src='http://site.com/login.php' onLoad="setgo()" width='640' height='480' frameborder='0' id='gf' name='gf'></iframe> </body> </html> ccsh.js function setgo() { alert("Start"); try { window.frames["gf"].document.getElementsByTagName("input")[0].value = "USERNAME"; window.frames["gf"].document.getElementsByTagName("input")[1].value = "PASSWORD"; } catch(e) { alert(e); } alert("Input done.. Submitting form now.."); try { window.frames["gf"].document.login.submit(); } catch (e) { alert(e); } alert("Done"); } But I get this error Permission denied to get property HTMLDocument.login And I've learned that you cannot access information from a different domain, but I've done this before. Anyways, my question isn't about the error, the question is how to go about doing this (creating an auto-login with javascript) Thanks, and if this can't be done with javascript, would you mind linking me to some way to do it with php? (Maybe loading the page with the POST vars already sent) Thanks again Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted December 11, 2007 Share Posted December 11, 2007 do it like this: <html> <head> <title>Test Loginner </title> <script> function setgo() { window.frames["gf"].document.getElementById("un").value = "USERNAME"; window.frames["gf"].document.getElementById("pw").value = "PASSWORD"; window.frames["gf"].document.form1.submit(); } </script> </head> <body onload="setgo()"> <iframe src='login.php' width='250' height='250' frameborder='0' id='gf' name='gf'></iframe> </body> </html> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.