https://github.com/aitoroses/iframe.js
It's a tool for working with Iframes, and get an easy communication between them.
https://github.com/aitoroses/iframe.js
Last synced: 11 months ago
JSON representation
It's a tool for working with Iframes, and get an easy communication between them.
- Host: GitHub
- URL: https://github.com/aitoroses/iframe.js
- Owner: aitoroses
- Created: 2015-01-24T20:18:32.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-01-24T20:18:48.000Z (over 11 years ago)
- Last Synced: 2025-03-01T08:30:05.825Z (over 1 year ago)
- Language: JavaScript
- Size: 402 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Iframe.js
It's a tool for working with Iframes, and get an easy communication between them
## Example of use
```js
/**
* Suppossing we have an scenario with 3 Iframes (1 parent and 2 childs of it)
* We execute this code from the first of the childs to access the second child.
* The second child has a function on it's window called 'hello()'
*
* In this example we will override that function and execute it from the child 1.
*
* window.hello = function() {
* alert("IM THE IFRAME 2")
* }
*
* child frames are sourced iframe1.html and iframe2.html
*/
var utils = new IframeUtils();
// Get directly the frame2 by searching recursively in its parent if it's not
// a child
var frame2 = utils.getIframeBySource("iframe2");
// when the frame 2 it's ready execute a callback
frame2.onReady(function() {
// Call its hello method
this.evaluate('hello()');
// Replace the hello method with a custom function
// accessing it's window
this._window.hello = function() {
alert('IFRAME 1 changed to IFRAME2')
}
// Evaluate again an check that it is diferrent result
this.evaluate('hello()');
});
```