Connecting Tech Pros Worldwide Help | Site Map

How can I access and element in the Top Window from Inside an Iframe

Mel
Guest
 
Posts: n/a
#1: Apr 18 '07
I need to access an element of my top window from inside an IFrame
within that window.

I tried:
parent.MYFRAME.document.getElementById("LHS");

and i get a "Access Denied"

is there a way to do this ?

thanks in advance

wisestpotato
Guest
 
Posts: n/a
#2: Apr 18 '07

re: How can I access and element in the Top Window from Inside an Iframe


On 18 Apr, 01:30, Mel <MelHer...@gmail.comwrote:
Quote:
I need to access an element of my top window from inside an IFrame
within that window.
>
I tried:
parent.MYFRAME.document.getElementById("LHS");
>
and i get a "Access Denied"
>
You should be using just:

parent.document.getElementById("LHS")

That is, the MYFRAME bit shouldn't be there.

Also, the document loaded within the iframe needs to be on the same
server as the parent document. Javascript can't access documents
across different domains for security reasons.

wp.

Mel
Guest
 
Posts: n/a
#3: Apr 18 '07

re: How can I access and element in the Top Window from Inside an Iframe


On Apr 18, 6:27 am, wisestpotato <wisestpot...@googlemail.comwrote:
Quote:
On 18 Apr, 01:30,Mel<MelHer...@gmail.comwrote:
>
Quote:
I need to access an element of my top window from inside an IFrame
within that window.
>
Quote:
I tried:
parent.MYFRAME.document.getElementById("LHS");
>
Quote:
and i get a "Access Denied"
>
You should be using just:
>
parent.document.getElementById("LHS")
>
That is, the MYFRAME bit shouldn't be there.
>
Also, the document loaded within the iframe needs to be on the same
server as the parent document. Javascript can't access documents
across different domains for security reasons.
>
wp.
when I use
parent.document.getElementById("LHS")

i get "Access Denied" can you please help ?

wisestpotato
Guest
 
Posts: n/a
#4: Apr 18 '07

re: How can I access and element in the Top Window from Inside an Iframe


On 18 Apr, 15:56, Mel <MelHer...@gmail.comwrote:
Quote:
when I use
parent.document.getElementById("LHS")
>
i get "Access Denied" can you please help ?
Is the document within the iframe on the same server, at the same
domain, as the parent document that is hosting the iframe? If not, you
will get the permission denied error.

wp.

Randy Webb
Guest
 
Posts: n/a
#5: Apr 18 '07

re: How can I access and element in the Top Window from Inside an Iframe


wisestpotato said the following on 4/18/2007 11:25 AM:
Quote:
On 18 Apr, 15:56, Mel <MelHer...@gmail.comwrote:
Quote:
>when I use
> parent.document.getElementById("LHS")
>>
>i get "Access Denied" can you please help ?
>
Is the document within the iframe on the same server, at the same
domain, as the parent document that is hosting the iframe?
Same domain required: yes (with an exception)
Same *server* required: Not even close.

The exception is sub-domains with the document.domain property set.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
wisestpotato
Guest
 
Posts: n/a
#6: Apr 19 '07

re: How can I access and element in the Top Window from Inside an Iframe


On 18 Apr, 18:39, Randy Webb <HikksNotAtH...@aol.comwrote:
Quote:
wisestpotato said the following on 4/18/2007 11:25 AM:
>
Quote:
Is the document within the iframe on the same server, at the same
domain, as the parent document that is hosting the iframe?
>
Same domain required: yes (with an exception)
Same *server* required: Not even close.
>
I did not say that the same server is required, not did I mean to
imply that - sorry if I was unclear. I was trying to whittle down the
possible problems by getting a clearer idea of the situation.

wp.

Closed Thread