Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 947
  • Last Modified:

Get the parent URL for an iFrame

I have a page on one domain.  (www.mypage.com/mydirectory/defaults.asp)

Within this page is an iframe that points to a different URL.  (www.differenturl.com/calendar.aspx)

When the calendar.aspx page loads in the iFrame I need it to get the URL of the page that loaded the iFrame.  So basically I need it get this:

www.mypage.com/mydirectory/

Is there a way to do this?  If so, can you please explain how.  Thanks!
0
cdemott33
Asked:
cdemott33
  • 2
  • 2
1 Solution
 
RaithZCommented:
That may be listed in the referrer information in the http headers.
0
 
cdemott33Author Commented:
Is there a way I could get this information using VB.NET?  If so, how?
0
 
Jitendra PatilSr.Software EngineerCommented:
Hi cdemott33

try this way,

.aspx code
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
        <body>
            <form id="form2" runat="server">
            <iframe id="Iframe1" runat="server" src="http://www.google.com" height="200px" width="200px"></iframe>
            <asp:Button ID="btnget" runat="server" Text="GetParentURL" />
            </form>
        </body>
</html>

.vb code

Imports System.Data
Public Class _Default
    Inherits System.Web.UI.Page
   
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       
    End Sub

    Protected Sub btnget_Click(sender As Object, e As EventArgs) Handles btnget.Click
        Response.Write(Request.UrlReferrer.ToString())
    End Sub
End Class

hope this helps.
0
 
cdemott33Author Commented:
Hi  patil786 -

When I click the button the response.write displays "www.google.com".  I want to get www.mypage.com/mydirectory/defaults.asp. Any thoughts on how I can do this?
0
 
Jitendra PatilSr.Software EngineerCommented:
can you post your code here.

are you referring any google code like google checkout, payment gateway etc..
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now