[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

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

Break out of an iframe within an iframe

I have a web page (let's call it PageA) that contains an IFrame (ifPageA). The page displayed within ifPageA (let's call it PageB) also contains an IFrame (ifPageB). The page displayed in ifPageB displays a repeater (calendar appointments). When the user clicks an appointment (which is a linkbutton), I want to open the EditAppointment page  in ifPageA.

Right now my linkbutton code is this, which doesn't work:

Dim strTransferTo As String
Dim scriptString As String = "<script language=JavaScript>"

strTransferTo = "../Calendar/Calendar.aspx?Mode=Edit&CalID=" & e.CommandArgument.ToString & "&Date=" & ViewState("Date").ToString
scriptString &= "document.getElementById('ifPageA').src= '" + strTransferTo + "';<"
scriptString &= "/"
scriptString &= "script>"

Page.RegisterStartupScript("OnChange", scriptString)

I am thinking I need some additional syntax to reference ifPageA, but I don't know JavaScript well enough to know what that is. Ideas?

0
rgrimm
Asked:
rgrimm
1 Solution
 
b1xml2Commented:
strTransferTo = "../Calendar/Calendar.aspx?Mode=Edit&CalID=" & e.CommandArgument.ToString & "&Date=" & ViewState("Date").ToString
scriptString &= "document.getElementById('ifPageA').src= '" + strTransferTo + "';<"
scriptString &= "/"
scriptString &= "script>"


assuming the IFRAME has the name "ifPageA", top.frames["ifPageA"].location.href  shd do the trick
scriptString &= "top.frames["ifPageA"].location.href = '" + strTransferTo + "';<"
scriptString &= "/"
scriptString &= "script>"

0
 
rgrimmAuthor Commented:
It works! I had to make one tweak though, which was to double-quote the embedded quotes:

strTransferTo = "../Calendar/Calendar.aspx?Mode=Edit&CalID=" & e.CommandArgument.ToString & "&Date=" & ViewState("Date").ToString
scriptString &= "document.getElementById(""ifPageA"").src= '" + strTransferTo + "';<"
scriptString &= "/"
scriptString &= "script>"

Page.RegisterStartupScript("OnChange", scriptString)
0

Featured Post

Technology Partners: 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!

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