我有两个网站..(MVC应用程序)
www.WebsiteA.com (其中有两个选项卡)如下所示。在它的".master“页面。
<ul id="module" class="module">
<li id="home"><%=Html.ActionLink("Home", "ActionHome", "Home")%></li>
<li id="Pay"><%=Html.ActionLink("Payment", "ActionPay", "Payment")%></li>
</ul>如果有人直接访问网站www.websiteA.com,这是他们应该看到的,两个标签,主页和付款。
还有另一个网站,比方说www.WebsiteB.com,在它的一个页面上有这个iframe。Iframe基本上指向第一个网站A。
这是网站B www.websiteB.com/linktoWebsiteA
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<iframe src="http://www.websiteA.com"</iframe>
</asp:Content>我的问题是:当有人通过websiteB中的Iframe访问网站时,我如何使网站A显示两个标签(www.websiteA.com),以及如何显示“只显示一个标签”(主页标签)。网站A inside Iframe应该只显示主页选项卡。谢谢你的点子/帮助。
发布于 2012-08-10 22:45:06
您可以在从iframe调用时传递查询字符串参数:
<iframe src="http://www.websiteA.com/?iframe=true"</iframe>然后使用iframe查询字符串参数显示所需的选项卡:
<ul id="module" class="module">
<li id="home"><%=Html.ActionLink("Home", "ActionHome", "Home")%></li>
<% if (!string.IsNullOrEmpty(Request["iframe"])) { %>
<li id="Pay"><%=Html.ActionLink("Payment", "ActionPay", "Payment")%></li>
<% } %>
</ul>另一种可能是使用javascript,因为如果你不想传递一些额外的指示(比如查询字符串参数),这是知道站点是否在iframe内运行的唯一方法。
<script type="text/javascript">
if (top !== self) {
// running inside an iframe => hide the tabs you don't want
}
</script>https://stackoverflow.com/questions/11904009
复制相似问题