views:

37

answers:

4

Hi,

My first post so apologies in advance for being a noob!

I want to write a script which will click a button on an external website (one which belongs to someone else). The button is defined as follows:

<input class="btnAdd" type="image" src="/superstore/i/b/btnAdd.gif" 
    id="i61109534-a" onclick="return a(61109534);">

Basically I want to have a button on my website that when pressed, redirects the user to the external website and automatically triggers the above onclick event. I have been using php so far but don't mind if the solution is using javascript or anything else for that matter!

Thanks in advance

A: 

It is not possible to click a button on an external website as of what i know :(

Sarfraz
A: 

That's generally a bad idea, for security reasons. Think of it the other way around: how would you like it if anybody could send users to your site and automatically click the "Logout" button (or, worse, the "delete account" button)?

If you need to do this, you'll need to be able to change the external website. For example, you could link to "http://external.website.com/page?auto_click=button_id". Then you'll have to change the external website's code to automatically click a button when the "auto_click" variable is set in the GET request.

Jeff Terrell
A: 

It cannot be done in PHP, as PHP executes server-side and has no control over the user's browser.

JavaScript would be your only solution, but what you're proposing to do is a massive breach of security and explicitly disallowed by design. It cannot easily be done, short of finding a vulnerability in the site you're linking to and injecting JavaScript into that page.

You might be able to accomplish something similar by including the other page in a frame/iframe, but I don't think that's allowed if the pages come from different domains; see cross-frame scripting.

meagar
A: 

As far as I know, that's how most tracking, ads and put-a-widget-in-your-site systems work. You just need to insert a call to the *.js file where the function is defined. From the source code of StackOverflow:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt;

Of course, you must kind of trust the remote site...

Álvaro G. Vicario