1

parent domain is

example.com/abc/

and the iframe's domain is

abcd.example.com/hhh/.

is it possible to access the dom element of parent?

Sougata Bose
  • 31,517
  • 8
  • 49
  • 87
  • considering you are using iframes, technically they are seperate DOMs – elzaer Oct 23 '13 at 03:52
  • is there any way to acces the parent dom by using something like postMessage or something else?? – Sougata Bose Oct 23 '13 at 03:55
  • 1
    See the following community wiki on this topic will help: [ways-to-circumvent-the-same-origin-policy] http://stackoverflow.com/questions/3076414/ways-to-circumvent-the-same-origin-policy – Ahsan Shah Oct 23 '13 at 04:23

2 Answers2

4

Is it possible? Yes. But only if you have permission to do so. Do you control both domains? If not then, no, this is not possible due to cross domain security restrictions.

Assuming you do have control over both sites you could use window.postMessage to facilitate this communication.

See this

Nick
  • 19,198
  • 51
  • 185
  • 312
  • postMessage seems to be [broken in IE10](http://stackoverflow.com/questions/16226924/is-cross-origin-postmessage-broken-in-ie10), I wonder if jQuery has something to deal with that... – Oleg Mikheev Oct 23 '13 at 04:00
1

Yes u can access it until both are on the same domain.

To access a parent element from iframe u can use javascript at child as follows:

parent.document.getElementById('elem');

To access any global element :

var a=parent.a
Vicky Gonsalves
  • 11,593
  • 2
  • 37
  • 58