Forum Discussion

JP_124708's avatar
JP_124708
Icon for Nimbostratus rankNimbostratus
Oct 11, 2013

How to redirect or change content in an iFrame

I'm trying to figure out a good way to be bale to change the content displayed in an iFrame. We have written an iRule that will do an HTTP::redirect, but it displays the redirect in the iFrame.

 

The iFrame is way to small to show the redirected page, so I'm looking for some other way to change the content in the iFrame.

 

This is for a PeopleSoft application. After logging on, it gives you a drop down menu along with other content on the screen. We want to change the behavior for some of the items and I've been doing it with HTTP::redirect's. The redirect works, it's just that it stays in the iFrame, which is expected.

 

But, we need a way to get out of the iFrame, or enlarge the iFrame.

 

  • Getting out of or enlarging an iFrame are generally client side HTML/JavaScript processes - the browser has to do it. I think you have a few options here:

    1. You could potentially modify the iFrame's dimensions as the (parent) page that defines it passes through the F5. This could make the iFrame larger, but also potentially mess up the intended layout of the page.

    2. You could add some JavaScript to the iFrame response that tells it to break out. Something like this:

      
      

    Probably the easiest way to do this is with a STREAM profile. Add a blank STREAM profile to the virtual server configuration and this iRule (modify as required):

    when HTTP_REQUEST {
        STREAM::disable
        HTTP::header remove "Accept-Encoding"
        if { [string tolower [HTTP::uri]] starts_with "/public2" } {
            set add_iframe_breaker 1
        }
    }
    when HTTP_RESPONSE {
        if { ( [info exists add_iframe_breaker] ) and ( [HTTP::header value Content-Type] contains "text" ) } {
            unset add_iframe_breaker
            STREAM::expression {@@@}
            STREAM::enable
        }
    }
    
  • i have a similar scenario.. So we have a web app that we don’t want users to get to the login ‎page.. the app should only be accessible through primary portal.. so ‎the main portal will send the following URL/URI through – ‎ ‎ ‎ https://www.secondary.com/app/index.aspx?authid={session-token} ‎

    ‎The use case I am trying to solve for is if a user enters the following – ‎ ‎ ‎

    https://www.secondary.com/app/index.aspx?authid=

    or

    https://www.secondary.com/app/index.aspx?authid={start-typing-stuff}‎ ‎ ‎

    this directs to a page with iframes.. top and side and body.. I found a URI ‎request going to a specific path that causes it but when I redirect with ‎the iRule, the iframe body gets redirects and not the whole page..

    the current irule i have is this -

    when HTTP_REQUEST {
        if {([string tolower [HTTP::uri]] starts_with "/app/index.aspx") and not ([string tolower [HTTP::uri]] contains "authid")}{
            HTTP::redirect "https://www.primary.com"
            }
        if {[string tolower [HTTP::uri]] starts_with "/app/engine/login.aspx"}{
            HTTP::redirect "https://www.primary.com"
            }   
        }
    

    when i do that, the top and side frames remain with the secondary formating and the body gets redirected..

  • i tried the iRule you suggested above like this -

    when HTTP_REQUEST {
        STREAM::disable
        HTTP::header remove "Accept-Encoding"
        if {([string tolower [HTTP::uri]] starts_with "/app/index.aspx") and not ([string tolower [HTTP::uri]] contains "authid")}{
            HTTP::redirect "https://www.primary.com"
            }
        if {[string tolower [HTTP::uri]] starts_with "/app/engine/login.aspx"}{
            set add_iframe_breaker 1
            HTTP::redirect "https://www.primary.com"
            }   
        }
    when HTTP_RESPONSE {
        if { ( [info exists add_iframe_breaker] ) and ( [HTTP::header value Content-Type] contains "text" ) } {
            unset add_iframe_breaker
            STREAM::expression {@@ @}
            STREAM::enable
        }
    }
    

    without any success..