Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #19562 > unrolled thread
| Started by | Andrew Poulos <ap_prog@hotmail.com> |
|---|---|
| First post | 2013-05-02 09:49 +1000 |
| Last post | 2013-05-03 20:03 +0100 |
| Articles | 10 — 6 participants |
Back to article view | Back to comp.lang.javascript
Know if element is in iframe Andrew Poulos <ap_prog@hotmail.com> - 2013-05-02 09:49 +1000
Re: Know if element is in iframe Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-02 02:19 +0200
Re: Know if element is in iframe Stefan Weiss <krewecherl@gmail.com> - 2013-05-02 02:32 +0200
Re: Know if element is in iframe Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-02 02:34 +0200
Re: Know if element is in iframe JJ <duh@nah.meh> - 2013-05-02 12:31 +0700
Re: Know if element is in iframe Stefan Weiss <krewecherl@gmail.com> - 2013-05-06 19:57 +0200
Re: Know if element is in iframe Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-07 10:09 +0200
Re: Know if element is in iframe Denis McMahon <denismfmcmahon@gmail.com> - 2013-05-02 14:41 +0000
Re: Know if element is in iframe Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-02 21:03 +0200
Re: Know if element is in iframe Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> - 2013-05-03 20:03 +0100
| From | Andrew Poulos <ap_prog@hotmail.com> |
|---|---|
| Date | 2013-05-02 09:49 +1000 |
| Subject | Know if element is in iframe |
| Message-ID | <ILqdneEisfWLNxzMnZ2dnUVZ_rWdnZ2d@westnet.com.au> |
I have a page with an iframe. The some elements in the page in the iframe call a function in the parent page and pass 'this' to it eg. <span onclick="window.parent.func(this);">blah</span> When I put an alert on the parameter in func I get [object HTMLSpanElement] irrespective of whether the element is in the iframe or the parent page. How can I distinguish between the two? Andrew Poulos
[toc] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2013-05-02 02:19 +0200 |
| Message-ID | <1612442.XvMfrxuTdh@PointedEars.de> |
| In reply to | #19562 |
Andrew Poulos wrote:
> I have a page with an iframe. The some elements in the page in the
> iframe call a function in the parent page and pass 'this' to it eg.
>
> <span onclick="window.parent.func(this);">blah</span>
>
> When I put an alert on the parameter in func I get
> [object HTMLSpanElement]
> irrespective of whether the element is in the iframe or the parent page.
>
> How can I distinguish between the two?
var thisDocument = document;
function func (target)
{
if (target.ownerDocument == thisDocument)
{
/* target is in the frameset document */
}
}
If the “ownerDocument” property was unavailable, you could compare the
references to the root element objects by traversing the trees upwards by
“parentNode”.
I strongly recommend not to attach vital functionality to “div” and “span”
elements.
--
PointedEars
Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | Stefan Weiss <krewecherl@gmail.com> |
|---|---|
| Date | 2013-05-02 02:32 +0200 |
| Message-ID | <klsc6d$4j2$1@news.albasani.net> |
| In reply to | #19563 |
On 2013-05-02 02:19, Thomas 'PointedEars' Lahn wrote: > I strongly recommend not to attach vital functionality to “div” and “span” > elements. Why not? - stefan
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2013-05-02 02:34 +0200 |
| Message-ID | <4675435.PYf6PuiV0t@PointedEars.de> |
| In reply to | #19564 |
Stefan Weiss wrote: > On 2013-05-02 02:19, Thomas 'PointedEars' Lahn wrote: >> I strongly recommend not to attach vital functionality to “div” and >> “span” elements. > > Why not? Because that does not work everywhere. -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | JJ <duh@nah.meh> |
|---|---|
| Date | 2013-05-02 12:31 +0700 |
| Message-ID | <1auhnw7p1qeut.6cmn6nrr6vus.dlg@40tude.net> |
| In reply to | #19565 |
On Thu, 02 May 2013 02:34:54 +0200, Thomas 'PointedEars' Lahn wrote: > Because that does not work everywhere. I don't see anything wrong with it. Could you provide some examples?
[toc] | [prev] | [next] | [standalone]
| From | Stefan Weiss <krewecherl@gmail.com> |
|---|---|
| Date | 2013-05-06 19:57 +0200 |
| Message-ID | <km8qtt$i4r$1@news.albasani.net> |
| In reply to | #19567 |
On 2013-05-02 07:31, JJ wrote: > On Thu, 02 May 2013 02:34:54 +0200, Thomas 'PointedEars' Lahn wrote: >> Because that does not work everywhere. > > I don't see anything wrong with it. > Could you provide some examples? I guess not. - stefan
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2013-05-07 10:09 +0200 |
| Message-ID | <9187070.gRQthCg9ES@PointedEars.de> |
| In reply to | #19649 |
Stefan Weiss wrote: > On 2013-05-02 07:31, JJ wrote: >> On Thu, 02 May 2013 02:34:54 +0200, Thomas 'PointedEars' Lahn wrote: >>> Because that does not work everywhere. >> >> I don't see anything wrong with it. >> Could you provide some examples? > > I guess not. Guess again. -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2013-05-02 14:41 +0000 |
| Message-ID | <klttu2$m0v$3@dont-email.me> |
| In reply to | #19562 |
On Thu, 02 May 2013 09:49:32 +1000, Andrew Poulos wrote: > I have a page with an iframe. The some elements in the page in the > iframe call a function in the parent page and pass 'this' to it eg. Is this a frame security thing? If the content of the iframe is not from the same host as the main page, I believe xss security prevents scripts from either manipulating the other? I've never tried communicating between an iframe and a parent docuemnt, but (a long time, several years ago) I wrote some code that happily communicated between frames in a frameset - is communication between parent and child fundamentally different to that between a frameset and a frame's content? -- Denis McMahon, denismfmcmahon@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2013-05-02 21:03 +0200 |
| Message-ID | <28497692.igfq1cy3Qc@PointedEars.de> |
| In reply to | #19583 |
Denis McMahon wrote: > On Thu, 02 May 2013 09:49:32 +1000, Andrew Poulos wrote: >> I have a page with an iframe. The some elements in the page in the >> iframe call a function in the parent page and pass 'this' to it eg. > > Is this a frame security thing? Unlikely here. > If the content of the iframe is not from the same host as the main page, > I believe xss security prevents scripts from either manipulating the > other? No, the Same Origin Policy (SOP) prevents that if the content of the iframe is not _accessed using_ the same URI scheme, _host name_ (that is, domain name, regardless where the content is hosted), or port number. XSS is a related, but different concept; it can be used to bypass the SOP. <http://en.wikipedia.org/wiki/Cross-site_scripting> > I've never tried communicating between an iframe and a parent docuemnt, > but (a long time, several years ago) I wrote some code that happily > communicated between frames in a frameset - is communication between > parent and child fundamentally different to that between a frameset and > a frame's content? No. -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> |
|---|---|
| Date | 2013-05-03 20:03 +0100 |
| Message-ID | <FQpnfkHSoAhRFw21@invalid.uk.co.demon.merlyn.invalid> |
| In reply to | #19598 |
In comp.lang.javascript message <28497692.igfq1cy3Qc@PointedEars.de>, Thu, 2 May 2013 21:03:20, Thomas 'PointedEars' Lahn <PointedEars@web.de> posted: >No, the Same Origin Policy (SOP) prevents that if the content of the iframe >is not _accessed using_ the same URI scheme, _host name_ (that is, domain >name, regardless where the content is hosted), or port number. It also erroneously prevents access if the page is being displayed locally (e.g. <file://localhost/c:/homepage/$.htm> (Opera representation) and is showing equally local content in the iframe [OK so far] AND the browser is current/recent Chrome (I see it in WinXP sp3). -- (c) John Stockton, Surrey, UK. ¬@merlyn.demon.co.uk Turnpike v6.05 MIME. Web <http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links. Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036) Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web