编辑模式下页面的 sharepoint 自定义样式
如果当前加载的页面处于编辑模式,我希望母版页中的以下代码片段运行,如下所示:
<!-- If edit mode, then add the following script -->
<script type="text/javascript">
document.documentElement.className += ' edit-mode';
</script>
<!-- End if -->
简单地说,我的脚本将向 html
edit-mode 类> 标签,就是这样。
我该怎么办?
谢谢
I want the following code snippet in master page to run if the current loaded page is in edit mode as follows:
<!-- If edit mode, then add the following script -->
<script type="text/javascript">
document.documentElement.className += ' edit-mode';
</script>
<!-- End if -->
simply, my script will add an edit-mode
class to the html
tag, that's it.
how can I do that ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以使用 PublishingWebControls:EditModePanel 控件。当页面处于编辑模式时,此控件将处理此标记中包含的信息。
You can use the PublishingWebControls:EditModePanel control. This control will process the information included in this tag when the page is in the Edit mode.
由于没有SharePoint专家,我已经做了一个解决方法来解决我的问题,下面我的解决方案有两个版本,第一个在jQuery中,第二个使用纯JavaScript,
主要是我试图寻找仅在编辑模式下存在的特殊类,例如
.ms-SPZoneLabel
是在编辑模式下包装 Web 部件区域的类,.edit-mode-panel
是包装字段以输入数据的类在文章页面中,以及wiki 页面中的.ewiki-margin
...如果有人有更好的解决方案(例如在服务器端确定的 ASP 标记)
请写下你的解决方案
since there are no SharePoint experts, I have done a workaround to solve my problem, and below my solution in two versions, first in jQuery, and second using pure JavaScript,
mainly i tried to look for a special classes that exists only in edit mode, for example
.ms-SPZoneLabel
is the class that wraps a web part zone in edit mode,.edit-mode-panel
is a class that wraps a field to entering data in article pages, and.ewiki-margin
in wiki pages...if someone have a better solution (like an ASP tag to determine that on server side)
please write down your solution
如果您将其用作书签,此代码确实可以工作:
我尝试将其转换为纯 Javascript,但它在我的 Firefox Javascript 控制台中不起作用。
我很感兴趣是否有人可以让它在纯 JavaScript 中工作!它告诉我:
错误:TypeError:thisdocument.forms.aspnetForm 未定义
源文件:Javascript 命令
第 2 行
小书签来自此人的网站:
http://blog.mastykarz.nl/sharepoint-developer-bookmarklets/
这里是另一个。它会启动编辑页面并打开侧边栏。这对我来说效果很好:
This code does work if you use it as a bookmarklet:
I tried to convert it to plain Javascript, but it won't work in my firefox Javascript Console.
I am quite interested if anyone can get it to work in plain javascript! It tells me:
Error: TypeError: thisdocument.forms.aspnetForm is undefined
Source File: Javascript Command
Line: 2
The bookmarklet came from this fellow's site:
http://blog.mastykarz.nl/sharepoint-developer-bookmarklets/
Here is another one. It starts the edit page with the sidebar open. This one works fine for me:
要获得所需的结果,您需要在母版页中添加以下代码。
To get the desired result you need to add the following piece of code in the masterpage.