passing data to an IFrame

6 replies
Hello all,

Is it possible to pass data to an IFrame? If so, how can it be done?

TIA
#data #iframe #passing
  • Profile picture of the author marketingtoools
    Your question is not clear. But this can help you. Posts containing 'pass data to iframe' - Stack Overflow
    {{ DiscussionBoard.errors[9094119].message }}
  • Profile picture of the author kilgore
    Passing data to an iFrame is generally prevented through browsers' cross site scripting protections. The only exception I know of is that you could pass GET variables to an iFrame by changing its src in the parent page.

    For instance, you could do something like this:

    <iframe src="http://www.example.com/somepage"></iframe>

    to

    <iframe src="http://www.example.com/somepage?name=Bob"></iframe>

    Passing JavaScript, POST or any other kind of data to an iFrame isn't going to work.
    {{ DiscussionBoard.errors[9095496].message }}
    • Profile picture of the author dgmufasa
      Thanks for the info. I guess such a page would have to be generated on the fly? Basically, I have another application that requires a login ID and password. When calling it from Wordpress, was hoping to be able to pass that in (instead of having the user see "LoginID/Password" boxes).
      {{ DiscussionBoard.errors[9105332].message }}
      • Profile picture of the author Thread7
        We need more info on what you are trying to do. You can simply pass data to an iframe in the tag itself. Such as <iframe src="http://www.warriorforum.com?id=username&password=thepass" ></iframe>

        Of course the above example is a little insecure. But maybe the data you need to pass doesn't need security? Maybe the iframe is on the same domain as the main page. If so, you have a ton of options - cookies, session variable, and more.

        I not the same domain and you need security, the top example still could help if you generate an encrypted session id and the two sites talk to one another's servers in the background to retrieve the necessary info.
        {{ DiscussionBoard.errors[9107503].message }}
        • Profile picture of the author brentb
          You could set up a mutual database and write to the database from one site and pull the live data via AJAX in the iFrame.
          {{ DiscussionBoard.errors[9138670].message }}
  • Profile picture of the author PradeepShivam
    Hi,

    yes u send data to iframe using query string for example "http://www.examplelink.com/testpage.php?id=4

    it send data using GET method form .

    or use ajax method to load into iframe , u can send POST method data also .
    {{ DiscussionBoard.errors[9138856].message }}

Trending Topics