Can A.js call a function from B.js?
No, the javascript need to be defined on your current page
Can A.js modify the DOM of page B.html?
Yes, but you need a reference AND have the same origin.
If page A have a reference to page B, it is possible for A to modify the DOM in B.
Page A can have a reference to page B if page A opened page B and saved the reference. Also page B can access page A via the opener property. You can open a new tab/page in javascript with the following code :
// Open a new window
var myWindow = window.open("", "myWindow", "width=200, height=100");
// Write some text in the new window
myWindow.document.write("<p>This is 'myWindow'</p>");
// Write some text in the window that created the new window
myWindow.opener.document.write("<p>This is the source window!</p>");
Same Origin Policy Limitation
The same origin policy limit what you can access. If the 2 pages are on different domains, you will not be able to access the window.document
property to read or write. Here is a list of what you can access when the other page is from a different domain.