locked
Iframe height in knockou js RRS feed

  • Question

  • User1308732545 posted

    Hi All, 

    I have a java script code snippet  below 

    $(document).ready(function () {
        setFrameHeight();
    });
    
    $(window).resize(function () {
        setFrameHeight();
    });
    
    function setFrameHeight() {
        var height = $(window).height();
        height = height - $('.page-header').outerHeight(true) - $('#Menus').outerHeight(true) - 72;
        $("#frame").height(height);
    }
    

    I have to convert this java script snippet to knockout js , I am very new to Knockout and have no clue how to do it , Could any one please help me ?

    Thanks

    Tuesday, September 20, 2016 10:30 AM

All replies

  • User-474980206 posted

    you don't. you convert this to vanilla javascript. what this code looks like depends on which browsers you wish to support. jQuery abstracts the code, you will have to test for the browsers you want to support and perform the same code:

    if you only want to support html 5 browsers, then ready can be replaced with something like:

    (function() {
       if ( document.readyState === "complete" ||
          ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
    	   window.setTimeout( ready );
    
       } else {
          document.addEventListener( "DOMContentLoaded", completed );
          window.addEventListener( "load", completed );
       }		
    
       function completed() {
          document.removeEventListener( "DOMContentLoaded", completed );
          window.removeEventListener( "load", completed );
          ready();
       }
    })();
    
    function ready() {
       // do your ready code here   
    }
    
    

    $('.page-header')  can be replaced with (html 5 browsers):

        document.querySelector(".page-header")

    see dom docs for measurements

    Tuesday, September 20, 2016 3:36 PM