如何在WebPart中重新调整大小? [英] How to ReSize in WebPart?
问题描述
大家好
我尝试制作一个 WebPart。我的代码可以自动调整页面的宽度。
但我希望比例调整高度,(1:1)?
请帮助我,Thx!
function ResizeIFrame( ){
if(window.parent == null)
return;
var senderId;
var params = document.URL.split("?")[1] .split("&");
for(var i = 0; i< params.length; i = i + 1){
var param = params [i] .split(" =");
if(param [0] .toLowerCase()==" senderid")
senderId = decodeURIComponent(param [1]);
}
var height = $(document).height()
var width =" 100%" // auto
var message ="< Message senderId =" + senderId +" >"
+" resize(" + width +"," + height +")< / Message>" ;;
document.getElementById(" senderId")。innerHTML = senderId;
window.parent.postMessage(message,'*');
}
$(文件).ready(
function(){
; ResizeIFrame();
});
< ClientWebPart Name =" ReSize"标题= QUOT;调整大小" Description =" ReSize Test" DefaultWidth = QUOT; 300" DefaultHeight =" 200">
注意: I  ;想要获得宽度 , 但是 $(文件).width() 它总是获得300px
如果你在IE 9及以上版本为什么不尝试HTML5 / CSS3媒体查询。
这样你就不需要编写JavaScript了,问题很容易通过帮助解决CSS3。
Hi all
I am try to make a WebPart. my code can automatically adjust the width of the page.
But I hope Proportional adjust the height, ( 1 : 1) ?
please help me, Thx!
function ResizeIFrame() { if (window.parent == null) return; var senderId; var params = document.URL.split("?")[1].split("&"); for (var i = 0; i < params.length; i = i + 1) { var param = params[i].split("="); if (param[0].toLowerCase() == "senderid") senderId = decodeURIComponent(param[1]); } var height = $(document).height() var width = "100%" //auto var message = "<Message senderId=" + senderId + " >" + "resize(" + width + "," + height + ")</Message>"; document.getElementById("senderId").innerHTML = senderId; window.parent.postMessage(message, '*'); }
$(document).ready(
function () {
ResizeIFrame();
});
<ClientWebPart Name="ReSize" Title="ReSize" Description="ReSize Test" DefaultWidth="300" DefaultHeight="200">
note: I want to get width , but $(document).width() it's alway get 300px
If you are on IE 9 and above why don't you try HTML5/CSS3 media queries.
That way you don't need to write JavaScript and problem can easily be solved with the help of CSS3.
这篇关于如何在WebPart中重新调整大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!