我似乎找不到正确的封装或前缀语法来引用位于xxxx站点集合中的图像。
现在,我有三个变体的一个图像,将应用于页脚。这些变体是基于站点集合选择的,因此我不能直接将图像设置为主页(除非我想创建三个主页,这对于单个图像来说是过分的)。
我尝试使用Javascript来设置img元素的源代码,使用CSS来设置容器元素的背景图像的url。都让我失望了。
在Javascript中,我尝试将元素的src属性设置为:
"<SharePoint:ProjectProperty Property='SiteUrl' runat='server' />/_catalogs/masterpage/Images/myimage.gif;"
"<% $SPUrl:~sitecollection/_catalogs/masterpage/Images/myimage.gif %>";
"~sitecollection/_catalogs/masterpage/Images/myimage.gif";
并将CSS的背景图像属性重复使用到div元素。但我所得到的只是错误,否则它不会翻译sharepoint代码。
有人知道我还能尝试什么吗?
发布于 2013-11-25 23:22:50
检查这些URL以供参考- http://www.vrdmn.com/2011/08/javascript-lmenubaseurl-varaible-for.html http://johnliu.net/blog/2012/2/3/sharepoint-javascript-current-page-context-info.html http://blogbaris.blogspot.com/2013/01/getting-web-url-with-sharepoint-2010.html
然后尝试下面的方法来获得URL。
<%script type="text/javascript">
var url = "<%= SPContext.Current.Site.Url %>";
</script>希望这能有所帮助!
发布于 2013-11-25 22:14:41
这个图像到底存放在哪里?它在发布站点的默认“图片”库中吗?如果是这样,你就走错路了。它将是“/PublishingImage/myImage.gif”。
https://stackoverflow.com/questions/20202580
复制相似问题