ドキュメントライブラリボタンの削除
-
09-12-2019 - |
質問
マイ文書ライブラリーでは、次のコードを使用してExplorerボタンを開くことに成功しました(コード1)。
<script type="text/javascript">
_spBodyOnLoadFunctionNames.push("hideToolbarItem()");
function hideToolbarItem() {
var doc = document.getElementsByTagName('ie:menuitem');
for (var i = 0; i < doc.length; i++){
itm = doc[i];
if (itm.id.match('OpenInExplorer')!=null){
itm.hidden=true;
}
}
}
</script>
.
Outlookボタンへの接続を非表示にする必要がある
私は両方のメニューボタンを参照しようとしましたが、それはうまくいきませんでした(コード2)
<script type="text/javascript">
_spBodyOnLoadFunctionNames.push("hideToolbarItem()");
function hideToolbarItem() {
var doc = document.getElementsByTagName('ie:menuitem');
for (var i = 0; i < doc.length; i++){
itm = doc[i];
if (itm.id.match('OpenInExplorer')!=null)
if (itm.id.match('OfflineButton')!=null){
itm.hidden=true;
}
}
}
</script>
.
同じコードを2回使用しない(コード3)
<script type = "text/javascript" >
_spBodyOnLoadFunctionNames.push("hideToolbarItem()");
function hideToolbarItem() {
var doc = document.getElementsByTagName('ie:menuitem');
for (var i = 0; i < doc.length; i++) {
itm = doc[i];
if (itm.id.match('OpenInExplorer') != null) {
itm.hidden = true;
}
}
}
</script>
<script type="text/javascript">
_spBodyOnLoadFunctionNames.push("hideToolbarItem()");
function hideToolbarItem() {
var doc = document.getElementsByTagName('ie:menuitem');
for (var i = 0; i < doc.length; i++) {
itm = doc[i];
if (itm.id.match('OfflineButton') != null) {
itm.hidden = true;
}
}
}
</script>
.
コード2と3の両方がエクスプローラで開くと再表示され、Outlookの消費に接続します。私はどちらもなくなります!JavaScriptについてはあまり知りませんので、私が間違っているのかの説明があります。 - )
解決
下記を使ってみてください:
<script type="text/javascript">
_spBodyOnLoadFunctionNames.push("hideToolbarItem()");
function hideToolbarItem() {
var doc = document.getElementsByTagName('ie:menuitem');
for (var i = 0; i < doc.length; i++) {
itm = doc[i];
if (itm.id.match('OpenInExplorer')!=null)
{ itm.hidden=true; }
if (itm.id.match('OfflineButton')!=null)
{ itm.hidden=true; }
}
}
</script>
. 他のヒント
リボンの物理的HTML要素をJavaScriptと隠すのとは対照的に、この種のもののためにSharePointオブジェクトモデルを使用するのは常により良いアプローチです。
これはあなたが始めるためのカップルのリンクです(2番目のものは特に「エクスプローラの開封」ボタンに具体的に話す):
http://www.learningsharePoint..com / 2010/10/24 / hid-ribbon-buttons-sharepoint-2010 - プログラムによる/
http://sharepointegg.blogspot。COM / 2010/02 /削除ボタンからRIBBON-IN-SHAREPOINT.HTML
所属していません sharepoint.stackexchange