-2

How can I access different page controls using JavaScript?

For example, I have two pages: Page1.htm and Page2.htm.
I write my JavaScript code in Page1.htm and I need to access a textbox or any other control which is placed in Page2.htm.

Regent
  • 5,142
  • 3
  • 21
  • 35
Sanoop
  • 119
  • 1
  • 2
  • 11

1 Answers1

1

Try it like,

$(function(){
    $.get('page2.html',function(html){
       console.log($(html).find('textarea'));
    });
});
Rohan Kumar
  • 40,431
  • 11
  • 76
  • 106
  • How can I achieve if the pages are in different domain. I am getting the following error. access-control-allow-origin' header is present on the requested resource. origin 'null' is therefore not allowed access – Sanoop May 06 '14 at 10:55
  • You should refer [loading-cross-domain-html-page-with-jquery](http://stackoverflow.com/a/17299796/1817690) – Rohan Kumar May 06 '14 at 11:47