468,245 Members | 1,646 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,245 developers. It's quick & easy.

Accessing IFRAME content question

Hi all,

I have a page with an IFRAME in it. From a script in the main ( parent )
page I instruct the IFRAME to load a specific URL. The URL contains
parameters that are processed by the server. The server then writes a result
cookie into the content destined for the IFRAME.

I am having issues accessing the cookie. If I use a debuger I can see the
cookie via a quickwatch looking at window.frames['name].document.cookie
however when I run the code the same variable is empty. Does anyone have any
ideas??

Many thanks for your responses//

Paul
Jul 23 '05 #1
4 4688
Paul Brant wrote:
Hi all,

I have a page with an IFRAME in it. From a script in the main ( parent )
page I instruct the IFRAME to load a specific URL. The URL contains
parameters that are processed by the server. The server then writes a
result cookie into the content destined for the IFRAME.

I am having issues accessing the cookie. If I use a debuger I can see the
cookie via a quickwatch looking at window.frames['name].document.cookie
however when I run the code the same variable is empty. Does anyone have
any ideas??

Many thanks for your responses//

Paul


Hi

Is the URL in the IFRAME on the same domain as the mainpage?

Regards,
Erwin Moller
Jul 23 '05 #2


Paul Brant wrote:

I have a page with an IFRAME in it. From a script in the main ( parent )
page I instruct the IFRAME to load a specific URL. The URL contains
parameters that are processed by the server. The server then writes a result
cookie into the content destined for the IFRAME.

I am having issues accessing the cookie. If I use a debuger I can see the
cookie via a quickwatch looking at window.frames['name].document.cookie
however when I run the code the same variable is empty. Does anyone have any
ideas??


The new page in the iframe needs to be loaded before document.cookie in
that frame window can have the new cookies so you need to wait to have
the page loaded.
As you want to access the cookies from the containing window it is best
you define a function there
function processCookies (cookies) {
...
}
and then in the new frame loaded in the iframe you do
if (parent && parent.processCookies) {
parent.processCookies(document.cookie);
}
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #3

"Erwin Moller"
<si******************************************@spam yourself.com> wrote in
message news:42***********************@news.xs4all.nl...
Paul Brant wrote:
Hi all,

I have a page with an IFRAME in it. From a script in the main ( parent ) page I instruct the IFRAME to load a specific URL. The URL contains
parameters that are processed by the server. The server then writes a
result cookie into the content destined for the IFRAME.

I am having issues accessing the cookie. If I use a debuger I can see the cookie via a quickwatch looking at window.frames['name].document.cookie
however when I run the code the same variable is empty. Does anyone have
any ideas??

Many thanks for your responses//

Paul


Hi

Is the URL in the IFRAME on the same domain as the mainpage?

Regards,
Erwin Moller


Hey Erwin,

While I do not specifiy a domain within the server code both pages load from
the same host !

Regards,

Paul
Jul 23 '05 #4

"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:42*********************@newsread2.arcor-online.net...


Paul Brant wrote:

I have a page with an IFRAME in it. From a script in the main ( parent ) page I instruct the IFRAME to load a specific URL. The URL contains
parameters that are processed by the server. The server then writes a result cookie into the content destined for the IFRAME.

I am having issues accessing the cookie. If I use a debuger I can see the cookie via a quickwatch looking at window.frames['name].document.cookie
however when I run the code the same variable is empty. Does anyone have any ideas??


The new page in the iframe needs to be loaded before document.cookie in
that frame window can have the new cookies so you need to wait to have
the page loaded.
As you want to access the cookies from the containing window it is best
you define a function there
function processCookies (cookies) {
...
}
and then in the new frame loaded in the iframe you do
if (parent && parent.processCookies) {
parent.processCookies(document.cookie);
}
--

Martin Honnen
http://JavaScript.FAQTs.com/


Hey Martin,

many thanks for your post. I have progressed as a result of it. Given I own
the source to the server I decided to move away from cookies. I am however
ensuring that the document is loaded before proceeding. My iframe now calls
setResult on the following:

var processResult = new function() {
var scratch;

this.setResult = function(result) {
scratch = result;
}

this.getLastResult = function() {
return scratch;
}
}
I see scratch get set. When the parent (main) window then calls
getLastResult i get undefined. If I debug I see the variable set corrently.
Again.. if you have any thoughts I would be grateful.

Paul
Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Julius Mong | last post: by
2 posts views Thread by Richie | last post: by
1 post views Thread by threepins | last post: by
2 posts views Thread by Jeronimo Bertran | last post: by
3 posts views Thread by CJ | last post: by
19 posts views Thread by k.karthikit | last post: by
14 posts views Thread by Aaron Gray | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.