网页书签链接

    技术2022-07-11  139

    网页书签链接

    I get a lot of requests from customers to add a link to their website that allows the user to "bookmark" their site. I generally try to get them to drop that idea. The functionality of an "add to favorites" link isn't cross-browser compatible -- neither Firefox or Opera will allow it. Internet Explorer does allow favorite links and most of the internet still uses IE, so I do have a script to accomplish this goal.

    我收到了很多来自客户的请求,要求向他们的网站添加链接,以使用户可以“标记”他们的网站。 我通常会设法让他们放弃这个想法。 “添加到收藏夹”链接的功能与跨浏览器不兼容-Firefox或Opera都不允许。 Internet Explorer确实允许收藏夹链接,并且大多数Internet仍使用IE,因此我确实有一个脚本可以实现此目标。

    代码 (The Code)

    /* BOOKMARK THE PAGE */ function bookmark() { if ((navigator.appName == 'Microsoft Internet Explorer') && (parseInt(navigator.appVersion) >= 4)) { window.external.AddFavorite(window.location,document.title); } else { alert('Don\'t forget to bookmark us! (CTRL-D)'); } }

    说明 (The Explanation)

    It's a pretty simple JavaScript function. The function first checks to see if the user is browsing using Internet Explorer. If so, the function makes the appropriate call to IE, providing the page URL and title. If the user doesn't use Internet Explorer, short instructions are provided to prompt the user's browser to to add the current page as a favorite.

    这是一个非常简单JavaScript函数。 该功能首先检查用户是否正在使用Internet Explorer浏览。 如果是这样,该函数将对IE进行适当的调用,并提供页面URL和标题。 如果用户不使用Internet Explorer,则会提供简短说明以提示用户的浏览器将当前页面添加为收藏。

    翻译自: https://davidwalsh.name/favorite-link-create-bookmark-link

    网页书签链接

    相关资源:jdk-8u281-windows-x64.exe
    Processed: 0.010, SQL: 9