Donotello
Donotello

Reputation: 157

How to click a button on a redirected page?

I have the following code on my initial page

<html ..
<script> 

<input type= "button" onClick="location.href('http:www.google.com')">

How can I click the OK button on the google page ones redirected using ONLY javascript. Is it possible ?

Upvotes: 0

Views: 43

Answers (2)

Jonathan Anctil
Jonathan Anctil

Reputation: 1037

I don't know why you want to click OK button on Google page, but if it's to launch search, why you don't try to redirect with search parameter like :https://www.google.ca/#q=google+search+javascript

Upvotes: 0

BenM
BenM

Reputation: 53228

No, once the user has been redirected away from your website, you cannot access the DOM any longer using JavaScript.

You could achieve something like this using a Chrome Plugin or some such, but thankfully this is not possible using native JavaScript code.

Upvotes: 3

Related Questions