Reputation: 7605
I have 2 sub domains
passwordservices.example.com
computers.example.com
All computers are attached to the computers.example.com
A workstation called PC123456 on the domain has a fully qualified name is
PC123456.computers.example.com
The web pages are hosted on passwordservices.
How can I write a javascript that's hosted on PC123456 And access DOM elements on password services.
Upvotes: 2
Views: 1229
Reputation: 14645
Basically, JS believes that even a subdomain such as img.yourdomain.com is a different domain from www.yourdomain.com. Because of that, AJAX across pages from those two subdomains will not work. Also if you have an iframe from one to another, you will not be able to refence JS vars or functions back and forth.
A way around this involves setting up an iframe html on one domain and then calling that iframe from the page on the other subdomain. You have to set the document.domain to the same thing on both the parent page and its iframe, in order for them to talk to each other.
document.domain = "yourdomain.com"
Source: tomhoppe.com
You might also want to look into Cross-Origin Resource Sharing
Good Luck!!
Upvotes: 3