Skip navigation
Currently Being Moderated

Query object in main page available to iframe?

Jul 30, 2012 8:21 AM

Tags: #iframe #query

Hello, everyone.


What is the best way to make a query object in a document available to an iframe (with a .cfm file as the source of the iframe) in that document?





  • Currently Being Moderated
    Jul 30, 2012 9:01 AM   in reply to WolfShade

    An iframe is just another window. If it is loading a .cfm file then how woudl you get that query object into any other .cfm file? 


    Don't let the source being loaded in an iframe confuse you. It's just another .cfm file. It doesn;t become an iframe til it reaches the client, and at that point it is long past ColdFusion's control. If you're thinking that the parent window will somehow pass a CF query to the iframe window, then you're thinking along the wrong track. The parent window is makign the request for the iframe document after it has left the server. It no longer has any concept of what a ColdFusion query is.


    If you need to ensure that the parent window and the iframe run the same dynamic query then you could do something like this:


    1. User requests the parent window

    2. Dyanmic query is run

    3. Query is cached in the App or session scope with a Unique key

    4. Iframe is created using that unique key (example: <iframe src="/childPage.cfm?queryKey=34jkldsflhsfdsdf" />)

    5. When iframe is loaded by the browser it receives that key, looks up the query in the cache and uses it instead of making a new query.



    Mark as:
  • Currently Being Moderated
    Jul 30, 2012 9:36 AM   in reply to WolfShade

    >> So, which is best, Application scope, or Session scope?


    If the data is user specific, then probably the session scope. Performance-wise, either one should be fine.


    >> And will a simple CFSET SESSION.VariableName = CFQUERYOBJECT work?  I didn't think a simple variable could contain a complex object?


    What makes a variable simple or complex is its content. 


    <cfset session.key = 1 /> Creates a simple variable


    <cfset session.key = structNew() /> Creates a complex variable


    Yes, session.key = queryObject will work just find.


    Mark as:
  • Currently Being Moderated
    Jul 30, 2012 9:44 AM   in reply to 12Robots

    Regarding "Yes, session.key = queryObject will work just find"


    cfquery name="session.something" accomplishes the same thing with one less command.

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points