Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery adjusting iframe height

This code was passed to me. It makes my iframe set to 100% height of the screen:

jQuery(document).ready(function(){var height = $(window).height();
             $('iframe').css('height', height)
         });

I am new to javascript. How can I edit this code to make it set to 90% height rather than 100%? Also, this code targets all iframes, is there any way to make it target a specific iframe (by its ID or NAME value)? You can fiddle with this code here if you wish: http://jsfiddle.net/VurLy/

like image 487
Henrik Petterson Avatar asked Aug 08 '12 21:08

Henrik Petterson


1 Answers

Multiply it by 90%?

jQuery(document).ready(function() {
    var height = $(window).height();
    $('iframe').css('height', height * 0.9 | 0);
});

As for targeting by ID or name, just pass the appropriate selector to $ instead of 'iframe'.

like image 130
Ry- Avatar answered Sep 21 '22 09:09

Ry-