![](/img/trans.png)
[英]How can I replace the content of the browsers content with the xhr.responseText
[英]How can I add some content to Chrome/Chromium browsers?
我需要在我的網站上加上“收藏我們”。 但是當我使用Google進行搜索時,所有結果都表明無法為Chrome / Chromium瀏覽器“添加書簽”。
所以我想要:
1-隱藏chrome / chromium瀏覽器中的內容。
或至少,
2-如果用戶的瀏覽器在點擊該按鈕后顯示為chrome / chromium,則顯示一條消息。
這是我的“Bookmark Us”腳本:
/** Bookmark Us */
function bookmark_us(url, title){
if(window.sidebar) // firefox
window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
var elem = document.createElement('a');
elem.setAttribute('href',url);
elem.setAttribute('title',title);
elem.setAttribute('rel','sidebar');
elem.click();
}
else if(document.all) // ie
window.external.AddFavorite(url, title);
} else {
}
/** Bookmark Us */
<a href="javascript:bookmark_us('URL','TITLE')">Bookmark Us!</a>
只需添加代碼即可顯示消息,說明最終else
Chrome / Chromium不支持該消息
/** Bookmark Us */
function bookmark_us(url, title){
if(window.sidebar) // firefox
window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
var elem = document.createElement('a');
elem.setAttribute('href',url);
elem.setAttribute('title',title);
elem.setAttribute('rel','sidebar');
elem.click();
}
else if(document.all) // ie
window.external.AddFavorite(url, title);
}
function hide_unsupported(){
if( !(window.sidebar || (window.opera && window.print) || document.all) ){
document.getElementById('bookmark').style.display = 'none';
}
}
window.onload = function (){
hide_unsupported();
}
<a id='bookmark' href="javascript:bookmark_us('URL','TITLE')">Bookmark Us!</a>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.