Question: I am trying to write a script, that automatically fills two input fields of another website. I looked at the website an saw, that the two input fields have the name 'userid' and 'userpass'.
I also wrote this very simple little piece of code to make it more understandable. (Lets say <http://www.w3schools.com> has two input fields with the names 'userid' and 'userpass')

```
<input type="button" value="Username" onClick="Start()" />
<input type="text" id="username" value="Username"/>
<input type="text" id="password "value="Password"/>

<script language="JavaScript">

function Start()
{
    var username = document.getElementById("username").value;
    var password = document.getElementById("password").value;;

    window.open("http://www.w3schools.com");
}

</script>

```

How can I pass the two variables and fill the value of them to the two input fields?
Is there any possible way?

Thank you

Answer: 
[See this question](https://stackoverflow.com/questions/169833/how-do-i-write-content-to-another-browser-window-using-javascript).

You're only able to do this if they're on the same domain (see [same-origin-policy](http://en.wikipedia.org/wiki/Same-origin_policy)). Otherwise there's a huge security issue.
You can load the website in an Iframe, and then access the fields that you need with something like this:

```
var name = $('iframe[name=select_frame]').contents().find('#select_name').val();

```