0

I have two websites.. (MVC applications)

www.WebsiteA.com (has two tabs in it) like this.. in its ".master" page.

   <ul id="module" class="module">       

        <li id="home"><%=Html.ActionLink("Home", "ActionHome", "Home")%></li>
        <li id="Pay"><%=Html.ActionLink("Payment", "ActionPay", "Payment")%></li>

    </ul>

If some one goes to the website directly at www.websiteA.com, this is what they should see, two tabs, Home and Payment.

There is another website lets say www.WebsiteB.com that has this iframe in one of its pages. The Iframe basically points to first website A.

This is website B www.websiteB.com/linktoWebsiteA

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <iframe src="http://www.websiteA.com"</iframe>

</asp:Content>

My question is : How can I make the website A show two tabs when some one goes directly to the url (www.websiteA.com) and how can I show "only one tab" (Home tab) when they access the website via the Iframe in websiteB. The website A inside Iframe should show only Home tab. Thanks for your ideas / help.

1 Answer 1

3

You could pass a query string parameter when calling from the iframe:

<iframe src="http://www.websiteA.com/?iframe=true"</iframe>

and then use the iframe query string parameter to show the tabs you want:

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

Another possibility is to use javascript as this is the only way to know whether the site runs inside an iframe if you don't want to pass some additional indication (such as a query string parameter).

<script type="text/javascript">
    if (top !== self) { 
        // running inside an iframe => hide the tabs you don't want
    }
</script>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.