2

Let's say that i have a webchat-application (external) loaded in my browser. As with all chats you'll get notifications on certain events like new message. The chat updates the DOM of the chat to reflect just that.

What i want to achieve is by searching this DOM for a particular occurrence (ie newmessage= 1) that i can use that information to trigger an alert (DOM-update) on a webpage i own.

I've seen examples of fetching/loading content/url with script but that would fetch a new instance of the page is my guess and that's not what i need.

In plain words. I have a web application that can show (in separate div) an iframe containing another chat that's not mine. People can switch views to my chat and the others. I want to receive a new message alert from the other chats when i'm viewing my own.

I hope it's somewhat clear what i'm asking. ;-)

I'm using PHP, Javascript/Jquery for my own chat.

T J
  • 42,762
  • 13
  • 83
  • 138
ingridsede
  • 329
  • 1
  • 5
  • 19
  • I don't think it's possible if you don't "own" the iframe :( i.e. if it's not from the same domain: http://stackoverflow.com/questions/17142285/access-iframe-content-from-parent-jquery – Rob Schmuecker Jul 06 '14 at 09:09
  • It's not manipulating the dom that i'm talking about i'll hope you understand. I know a bit about samedomain policy's but do they also have to do with just reading the dom? – ingridsede Jul 06 '14 at 09:14
  • Are you trying to access anything in the iFrame from a parent page not on the same domain? – Rob Schmuecker Jul 06 '14 at 09:23
  • Yes, i want to read that dom to check for an occurrance of a changed elements value. – ingridsede Jul 06 '14 at 09:32
  • OK - so you answered that you do want access to the iFrame, but if you do not have "edit" access to the iFrame then you're out of luck I'm afraid. http://stackoverflow.com/questions/364952/jquery-javascript-accessing-contents-of-an-iframe http://stackoverflow.com/questions/5181911/access-child-iframe-dom-from-parent-page – Rob Schmuecker Jul 06 '14 at 09:42
  • Does the chat application you iframe use anything like html5 push state to change the current URL when a message comes in? – brysgo Jul 10 '14 at 01:30
  • I really do'nt know. How can i check for that? – ingridsede Jul 13 '14 at 10:32

1 Answers1

1

This would violate the same origin policy:

In computing, the same-origin policy is an important concept in the web application security model. The policy permits scripts running on pages originating from the same site – a combination of scheme, hostname, and port number1 – to access each other's DOM with no specific restrictions, but prevents access to DOM on different sites.

Adam
  • 4,590
  • 10
  • 51
  • 84