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

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


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

try this way,

.aspx code
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
            <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" />

.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
    End Sub
End Class

hope this helps.
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?
Jitendra PatilSr.Software EngineerCommented:
can you post your code here.

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

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