JQuery iframe height adjustment

This code has been passed to me. This makes my iframe set to 100% screen height:

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

I am new to javascript. How can I edit this code to set it to 90%, not 100%? Also, this code is for all iframes, is there a way to make it target a specific iframe (by its identifier or NAME)? You can play here if you want: http://jsfiddle.net/VurLy/

+5
source share
3 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 $instead 'iframe'.

+9
source
jQuery(document).ready(function(){
    $('#YOUR_FRAME_ID_HERE').css('height', '90%')
});​
+2
source

jquery , , $('# scoop') , $('. scoop') - scoop

iFrame, , , .

 jQuery(document).ready(function() {
   var height = $(window).height();
   $('#scoop').css('height', '90%'); 
});
0
source

All Articles