动态的SharePoint Web部件宽度和高度

7
我正在尝试动态调整SharePoint网页上Web部件的宽度和高度,以使其填满整个可用空间。似乎没有办法从SharePoint Web部件属性编辑器窗口中选择宽度和高度的百分比。而且,通过代码动态设置Web部件实例会导致SharePoint抛出异常,指出不支持比例尺寸。是否有任何方法可以使用JavaScript来实现这一点?我看到类似的东西使用jQuery完成,但不完全符合我的要求(而且我对jQuery不够熟悉,无法自己想出解决方案)。

学习jQuery真的非常值得。它的学习曲线相当短,而且EndUserSharePoint上有大量的示例:http://www.endusersharepoint.com/?cat=513 - Alex Angas
2个回答

3

有一个Web部件可用,在这里执行此操作。您还可以在TechNet社区上查看来自“potta vijay kumar”的解决方案(我也在那里找到了该Web部件):

function calcHeight() 
{ 
  //find the height of the internal page 
    var the_height= 
    document.getElementById('contentpage').contentWindow. 
      document.body.scrollHeight; 

  //change the height of the iframe 
  document.getElementById('contentpage').height= 
      the_height; 
}

contentpage 是 iframe 的 ID。

EndUserSharePoint 提供了一个 jQuery 解决方案


1
这是我所做的:
中间 webpart 中有一个 iFrame,在其中根据左侧 web part 菜单加载网页。因此,我取出了包含这两个 webpart 的 元素(它是设置为 ms-bodyareaframe 类的 元素)。
var head=$('td.ms-bodyareaframe');
$("#myFrame").height(head.position.height()).attr('src',unescape(loc));
$("#myFrame").parent().height(head.height()-50);

这将完美地调整包含 iframe 的 Web 部件的大小。

注意:这可能不适用于所有情况。


iframe:有时候带来的麻烦比它所值得的还要多。 - user166390

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接