Reputation: 715
I have a page which contains several iframes. The pages in these iframes keep updating themselves with numbers (they all use the same library) and dates, and often contain divs that have the same IDs as a div in other iframes.
Some of these numbers go through a function to add commas to make them look pretty, but some are designed to hold dates so they don't call that function. The divs to update are selected with document.getElementByID.
My problem is sometimes (rarely, but if you leave the page up for a day you'll often see a few instances) the dates are having commas added into them (which screws up the date formatting, of course). The page script running in that iframe does not call the addCommas function.
My guess is that because the div with the date in it may have the same id as one in another iframe, if they run at the exact same time the engine may be confusing the two. Does that sound plausible?
I was hoping that being in different pages the running scripts would be completely independent of each other (and that documentX.divIDA would be entirely separate from documentY.divIDA, even if both are contained in iframes inside documentV), but are they not?
I've set up a test by opening one of the pages on it's own and I'll leave it undisturbed over the weekend, to confirm it is caused by interference from another page, but I thought I'd ask the experts anyway.
Upvotes: 0
Views: 420
Reputation: 245459
Content loaded in an iframe is completely independent of the page that loads it (unless there is explicit code to communicate between them...but you would've written that and known about it). There shouldn't be any possibility that a script executing for one iframe could change content in another.
I would open up the JavaScript debugger for your browser, load the page, set a breakpoint for the script running on one of the date iframes, and see when the addComma()
function is called.
Upvotes: 1