Navigation Menu

Skip to content

Commit

Permalink
Avoid cross domain errors when accessing iframe contents
Browse files Browse the repository at this point in the history
  • Loading branch information
philgyford committed Apr 5, 2015
1 parent e40b6ef commit fceddc7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions public/js/reader.js
Expand Up @@ -1045,10 +1045,15 @@ var reader = {
// So for each of them, find the 'body' element of the included page
// and set the iframe to the height of it.
$('iframe', $obj).each(function(idx){
$body = $(this).contents().find('body');
if ($body) {
$(this).height($body.outerHeight(true));
};
// Because we're on http, if the iframe contains an https request,
// like to youtube.com, the contents() causes an exception. For now,
// we'll just move on if that happens.
try{
$body = $(this).contents().find('body');
if ($body) {
$(this).height($body.outerHeight(true));
};
} catch(e) {};
});

// The height of all the elements that don't change from one article to
Expand Down

0 comments on commit fceddc7

Please sign in to comment.