I am trying to click a link on another page(I do not have access to that page) which loads a JS function.
So can I call that function from my page thru a href=”” or thru onClick=””
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t call a function remotely from another page. Besides, you already left your page by then.
Unless…
that other page is somehow loaded to your page (AJAX+CORS or AJAX+proxy server maybe) and it’s contents parsed on your page.
that other page has some logic that reads hashtags or query strings and executes corresponding functions. This could work inter-domain via iframes, as you are indirectly controlling the iframe via it’s hash/query string.
that other page could be loaded via iframes. iframes would work if “I do not have access to that page” meant that you just don’t have access on the current subdomain but both live on the same top domain.
Subdomain iframe communications can work. Pages on
example.comandsubdomain.example.comcan talk to each other butexample1.comandexample2.comcan’t talk to each other because both live on different domains. See the other answer regarding the Same Origin Policy.