By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,665 Members | 1,229 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,665 IT Pros & Developers. It's quick & easy.

Accessing IFRAME content question

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a


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

P: n/a

"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

P: n/a

"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.