有没有办法从Iframe的内容获取父网址? [英] Is there a way to get the parent URL from an Iframe's content?

查看:89
本文介绍了有没有办法从Iframe的内容获取父网址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在旧网站的asp页面的iframe中运行c#.net应用程序。访问Asp页面的会话信息有点困难,所以我想让我的.net应用程序简单地验证它是从一个已批准的页面调用的,或者立即停止。

I'm running an c# .net app in an iframe of an asp page on an older site. Accessing the Asp page's session information is somewhat difficult, so I'd like to make my .net app simply verify that it's being called from an approved page, or else immediately halt.

有没有办法让页面找到它的父文档的url?

Is there a way for a page to find out the url of it's parent document?

推荐答案

top.location.href

但是,只有当两页(iframe和主页面)是从同一个域中提供的。

But that will only work if both pages (the iframe and the main page) are being served from the same domain.

这篇关于有没有办法从Iframe的内容获取父网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆