Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass values into iframe not using GET

I have an iframe that I was formally creating using a url with some vars that I was passing in as a GET. Is it possible to set the source page and pass in the variables as a POST or something? Or really, if it's possible to somehow get at the variables stored in the parent I'd be fine with that as well.

like image 820
keybored Avatar asked May 04 '11 20:05

keybored


2 Answers

Use window.parent from within the iframe.

In the parent window:

window.passingObj = { "key" : "value" };

In the iframe:

alert(window.parent.passingObj["key"]); // value
like image 191
Alec Gorge Avatar answered Sep 19 '22 17:09

Alec Gorge


Two helpful posts:

iframe accessing parent DOM? (iframe to parent)

Invoking JavaScript code in an iframe from the parent page (parent to iframe)

like image 23
farinspace Avatar answered Sep 21 '22 17:09

farinspace