How to fill the form on another domain

N

nte

Hi.

I have a site where users can open their profiles and provide some
personal data.

On a user's button click, I want to open a new window and show some
page that
is hosted on another domain (I don't have any access to the code on
another domain).

Now since I already have the data necessary to fill the form on
external page, I
would like to do it with javascript instead of making the user fill
the same thing
over again.

This is what I have tried to do:


var targetWindow = window.open ('http://www.targetsite.com');

targetWindow.document.getElementById("field1").value = "value1";
targetWindow.document.getElementById("field2").value = "value2";
targetWindow.document.getElementById("Button").submit();


Of course, this works only when this code snippet is executed on the
same domain as the form that I want to fill (targetsite). Otherwise, I
receive
Access is denied error on the line where I want to fill field1.


How to solve this problem?

Many thanks.
 
V

VK

Hi.

I have a site where users can open their profiles and provide some
personal data.

On a user's button click, I want to open a new window and show some
page that
is hosted on another domain (I don't have any access to the code on
another domain).

Now since I already have the data necessary to fill the form on
external page, I
would like to do it with javascript instead of making the user fill
the same thing
over again.

This is what I have tried to do:

var targetWindow = window.open ('http://www.targetsite.com');

targetWindow.document.getElementById("field1").value = "value1";
targetWindow.document.getElementById("field2").value = "value2";
targetWindow.document.getElementById("Button").submit();

Of course, this works only when this code snippet is executed on the
same domain as the form that I want to fill (targetsite). Otherwise, I
receive
Access is denied error on the line where I want to fill field1.

How to solve this problem?

You can't.

P.S. Presumed that you cannot change default security settings on each
client machine.
 
I

Ivo

On a user's button click, I want to open a new window and show some
page that is hosted on another domain (I don't have any access to the
code on another domain).
Now since I already have the data necessary to fill the form on
external page, I would like to do it with javascript instead of making
the user fill the same thing over again.
This is what I have tried to do:

var targetWindow = window.open ('http://www.targetsite.com');

targetWindow.document.getElementById("field1").value = "value1";
targetWindow.document.getElementById("field2").value = "value2";
targetWindow.document.getElementById("Button").submit();

Of course, this works only when this code snippet is executed on the
same domain as the form that I want to fill (targetsite). Otherwise, I
receive
Access is denied error on the line where I want to fill field1.
How to solve this problem?

Filling in the formfields on the page of the other site is not going to
happen. But you can look at the source, see where their form is being sent
to, and then make up a form on your own domain with fields of the same name
and send it to the same place. If their code doesn't check the address from
which the form is coming then the result will be just the same.
HTH, i.
http://4umi.com/web/javascript/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,691
Members
48,796
Latest member
Greg L.

Latest Threads

Top