简体   繁体   English

如何向Chrome / Chromium浏览器添加一些内容?

[英]How can I add some content to Chrome/Chromium browsers?

I need to put a "Bookmark us" in my website. 我需要在我的网站上加上“收藏我们”。 But as I searched using Google all the results conclude that no way to do "Bookmark us" for Chrome/Chromium browsers. 但是当我使用Google进行搜索时,所有结果都表明无法为Chrome / Chromium浏览器“添加书签”。

So I want to either: 所以我想要:

1- Hide the content from chrome/chromium browsers. 1-隐藏chrome / chromium浏览器中的内容。

or at least, 或至少,

2- Show a message if the user's browser is chrome/chromium after clicking that buttong. 2-如果用户的浏览器在点击该按钮后显示为chrome / chromium,则显示一条消息。

Here is my "Bookmark Us" script: 这是我的“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>

Just add code to show the message saying that it isn't supported on Chrome / Chromium in the final else 只需添加代码即可显示消息,说明最终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.

相关问题 如何用xhr.responseText替换浏览器内容的内容 - How can I replace the content of the browsers content with the xhr.responseText 如何访问webkit浏览器中的粘贴文件? (作为Google Chrome) - How can I access pasted file in webkit browsers? (as Google Chrome) firefox 的多帐户容器扩展可以在 chrome 或基于 chromium 的浏览器中复制吗? - Can firefox's multi-account containers extension be replicated in chrome or chromium based browsers? 如何为所有浏览器设置iFrame内容的高度? - How can I set the height for iFrame content for all the browsers? 如何在Chrome扩展程序的内容脚本中将事件监听器添加到Google表格链接? - How can I add event Listener to google sheets link in chrome extension's content script? 如何将 Google 跟踪代码管理器添加到 chrome 扩展内容脚本? - How can I add Google Tag Manager to chrome extension content-scripts? 如果最后一个td(8)包含一些内容,如何在第二个td中添加类? - How can I add class to second td in row if last one td (8) has some content? IE和Firefox渲染不正确,但在Chrome,Safari和Chromium浏览器中却没有 - IE & Firefox rendering incorrectly but not in Chrome, Safari & Chromium browsers 当我在Google chrome扩展程序中的内容脚本的帮助下将鼠标悬停在页面的每个iframe上时,该如何向其添加按钮? - How can I add button to every iframe of the page when I hover upon it with the help of content script in google chrome extension? 如何在Chrome和其他现代浏览器中使用离线事件和在线事件? - How can I use onoffline and ononline events in Chrome and other modern browsers?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM