Resize Interwiki Innerscript

InterWikiに必要なスクリプト

var isResizeCatch = false;//Trigger
var ParentWindow;//Contain Parent Frame
document.addEventListener("DOMContentLoaded",function(){
   //Get Parent Frame
    ParentWindow = parent.postMessage ? parent : (parent.document.postMessage ? parent.document : undefined);
 
    //Set Event Method that if It catched Message from Parent Frame
    window.addEventListener("message",function(event){
        switch(event.data){
        case "Request your Height":
        //If it receive request,it begin send own heigth to parent frame
        isResizeCatch = false;
        //If getting own parent frame was successed,It start to post own height to parent frame
        if (typeof(ParentWindow) != "undefined") {
        postMyHeight();
        }
        break;
        case "I got your Height":
        //If it receive resize completed message,It stop posting
        isResizeCatch = true;
        break;
        }
    });
 
    //Post Method
    function postMyHeight(){
        //post
        ParentWindow.postMessage(getMyHeight(),"*");
        //Repeated action for transmission failure
        if(!isResizeCatch){
        setTimeout(postMyHeight,5);
        }
    }
 
    function getMyHeight() {
        //Operation to acquire the height according to the browser
        if (document.body.scrollHeight) {
            return document.body.scrollHeight;
        }
        if (document.height) {
            return document.height;
        }
        return document.body.offsetHeight;
    };
});
特に指定がない限り、このサイトのコンテンツには次のライセンスが適用されます: Creative Commons Attribution-ShareAlike 3.0 License