View Full Version : retreving the pages name from a iframe

03-18-2004, 04:30 PM

is it possible for me to get the main pages name from within a IFRAME?

If so, how and is it cross browser safe technique?

03-18-2004, 06:26 PM
If it is in the same domain then I believe you could use parent.document.title to grab the title of the main page and parent.location.href to get the document. I have not tested this so I can't say for sure.

03-18-2004, 06:30 PM
i need it to work for same and different domain..not possible?

03-18-2004, 07:36 PM
Due to security restrictions you cannot grab the info for a page that is in another domain.

03-18-2004, 10:55 PM
Would this be possible.

Domain#1 creates a javascript section on every page, and creates a variable that holds the name of the current page.

Then, in the IFRAME (from another domain possibly) it simply looks for that variable, if it exists, then use that since it contains the URL of the main page.

Is that a clean solution?

03-18-2004, 11:06 PM
How can I check if the parent page has a Varialbe created?


03-19-2004, 04:28 AM
As has been said, you cannot grab data from another domain. You will get an access denied error.