1 Reply Latest reply on Jan 19, 2007 1:30 PM by insuractive

    Javascript And iframe

      I currently have a script that I run on one page where the user can change the stylesheet.
      What I want to do is create a page with an iframe where the user can choose the stylesheet from my cfm page (lets call it page1.cfm) and pass a variable (the stylesheet choice) to a cfm page (lets call page2.cfm) within an iFrame. Both cfm files are on my server.

      Any suggestions?
        • 1. Re: Javascript And iframe
          insuractive Level 3
          I see a few possibilities:

          1) Store the stylesheet choice in a session variable and the use coldfusion to link in the correct stylesheet in your iFrame. You would have to submit or reload your parent page and that would force your iFrame page to reload.

          2) Have your iFrame CFM page accept the stylesheet choice as a URL variable and dynamically link in the correct stylesheet in CF. You could use javascript to set the URL for the iFrame page (e.g. myIFrame.cfm?stylesheet=green.css) once a client clicks on a stylesheet choice.

          3) Or you could do everything with javascript exactly how your code above is set up, you would just have to reference myFrame.document.styleSheets to set the stylesheet for the iFrame page. However, the advantage 1&2 have over this choice is using coldfusion will allow you to set the stylesheet choice in a persistent variable (i.e. session, client, etc) that will stay the same no matter how many pages the client browses to in the iFrame

          hope that helps.