NewLearner
NewLearner

Reputation: 116

set Element in external Url using JavaScript

I want to set a value in a Textbox which is present in external url. Im currently using this snippet

function func(){
    var childPage = window.open("extenal url(like www.google.com)");
    var textbox = childPage.document.getElemntsByName('textboxName')[0];
     textbox.value ="something";
}

But i'm getting "Access is denied" while retrieving the element ref.

Can we set any textbox of extenal url within our application by any other way. Thanks

Upvotes: 0

Views: 52

Answers (1)

Jamie Barker
Jamie Barker

Reputation: 8246

Simple answer, No. If browsers allowed this there would be serious security flaws.

The only way you can update your textbox is by running the JavaScript from within the website in the iframe.

You would then do parent.document.getElementsByName('textboxName')[0];

Upvotes: 1

Related Questions