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=""
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=""
If it's on a different domain and you can't change its content, then you can't do it due to the same origin policy. Sorry. You'll have to find a different way to achieve whatever you're trying to do.
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.com
and subdomain.example.com
can talk to each other but example1.com
and example2.com
can't talk to each other because both live on different domains. See the other answer regarding the Same Origin Policy.