"Grzesiek" <grzechu83@NOSPAM_CUT_ME.gazeta.pl> wrote in message
news:dd**********@inews.gazeta.pl...
Hi!
I have created page which contains some menu buttons and <iframe> with
sub-page. Each menu action on the master web site should change content of
iframe (by changing src attribute). But how to detect when user has opened
subpage not in master's <iframe> ? Is it possible to obtain reference to
master's page from sub-page ? When I'm trying to do this using Page.Parent
I
get null exception :(
[snip]
Hi Grzesiek,
As far as I know, this needs to be done in javascript.
If you look on the MSDN site, they keep every page within the MSDN frameset.
So if you enter a url like :
http://msdn.microsoft.com/workshop/a...ties/top_1.asp
It will redirect you to
http://msdn.microsoft.com/library/de...ties/top_1.asp
If you look at the code on thier page, you will see the code to redirect.
(hint: search for "top == self").
The MSDN script just checks if you opened the page directly, but it doesn't
check if it was opened within an iframe on another site. If you are trying
to avoid this, you should look into window.top.location.href
I've included a small example of what window.top.location.href returns.
Good luck.
--
Regards,
John MacIntyre
http://www.johnmacintyre.ca
Specializing in; Database, Web-Applications, and Windows Software
The parent page with an iframe
-- p.htm --
<html>
<body>
<iframe src="c.htm" frameborder="yes"></iframe>
</body>
</html>
-------
The child page
-- c.htm --
<html>
<head>
<script language="javascript">
function body_onLoad()
{
lbl.innerText=window.top.location.href;
}
</script>
</head>
<body onload="body_onLoad();">
<label id="lbl">Not Set</label>
</body>
</html>
-------
Open the p.htm page & the c.htm pages seperately and see what url is
returned.