//Global Variables used in different functions. var widthSelected=null; var senderId; var hostUrl = null; //Main function to change the size dynamically. function ResizeAppPart() { if (window.parent == null) return; // Extracts the host url and sender Id values from the query string. var params = document.URL.split("?")[1].split("&"); for (var i = 0; i < params.length; i = i + 1) { var param = params[i].split("="); if (hostUrl == null) { hostUrl = decodeURIComponent(param[1]); } if (i == (params.length - 1)) senderId = decodeURIComponent(param[1]); } var height = $(".slider").height(); // Keeping the height of the app part constant. widthSelected = "100%"; //use postmessage to resize the app part. var message = "<Message senderId=" + senderId + " >" + "resize(" + widthSelected + "," + height + ")</Message>"; window.parent.postMessage(message, hostUrl); }
原文:https://www.cnblogs.com/Javi/p/10936987.html