Skip to content

Instantly share code, notes, and snippets.

@FGRibreau
Created November 30, 2010 07:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FGRibreau/721290 to your computer and use it in GitHub Desktop.
Save FGRibreau/721290 to your computer and use it in GitHub Desktop.
jQuery iFrame
//Find the iframe in the current document
var doc = $('#myIframe').contents()[0];
//Get the iframe's window context
var iFrameWindow = 'defaultView' in doc? doc.defaultView : doc.parentWindow;
//Now we can get jQuery by doing iFrameWindow.$ or iFrameWindow.jQuery
iFrameWindow.$('selector').data('key')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment