Cross-browser bookmarking of a page is implemented with using JavaScript. To add a page to Favorites Internet browsers Explorer and browsers running on the IE engine is called standard method AddFavorite. However, there is one important detail here. If the IE page is opened as an embedded object in another application, for example in plugins or when using components for working with html, then the window.external object is present, but its AddFavorite method does not work. This is the most common mistake made by developers who simply copy code from each other without understanding and testing it. It would also be a big mistake to use only this one method on your website.

Gecko-based browsers such as Firefox, Netscape, K-Meleon and others have a window.sidebar object and a method for adding addPanel . The third parameter of the method is undocumented and optional, so in the script it is simply replaced with an empty string. Please note that by default the link is not added to bookmarks, but to sidebar browser. To add a page to the desired bookmark folder, select it from the drop-down menu.

For Opera browser The bookmarking link must have the rel="sidebar" attribute. But if this attribute is set immediately by default, then some browsers like Netscape will handle the bookmarking function twice: the first time through a script and the second time through the rel attribute. Therefore, you will have to change the link attributes dynamically, having previously determined the browser by checking the opera object type.

If none of the above methods worked, then there is no need to display an error message or, even worse, silently terminate the script. It would be much more correct to show the user an available solution to the problem, for example, offer to manually press the key combination Ctrl+D.

Now that we have all the initial data, we can write a cross-browser script to bookmark the page. I got something like this:

// Add to Favorites function add_favorite(a) ( title=document.title; url=document.location; try ( // Internet Explorer window.external.AddFavorite(url, title); ) catch (e) ( try ( // Mozilla window.sidebar.addPanel(title, url, ""); ) catch (e) ( // Opera if (typeof(opera)=="object") ( a.rel ="sidebar"; a.title=title; a.url=url; return true; else ( // Unknown alert("Press Ctrl-D to bookmark the page"); ) ) return false; )

Add to Favorites

You can see a working example of the implementation right on this page. The use of try-catch constructs allows the script to work correctly in any non-standard situations, for example in an IE Tab window opened in Firefox browser. The script also works correctly in various exotic browsers that cannot be uniquely determined through UserAgent or DOM properties. All vaunted commercial products like DLE are silently broken down in this situation.

This article will walk you through different ways to add folders, files, and programs to your Favorites list. file manager Windows operating system - Explorer.

In the operating room Windows system, in Explorer there is a list of “Favorites”. To this list operating system by default, links are added to certain folders (for example, “Desktop”), as well as to the folders of some programs after they are installed (for example, cloud file storage folders Google Drive, OneDrive, Yandex.Disk and others).

You can easily add other new folders to the Favorites list, or remove folders located there from the Favorites list.

First, let's look at adding links to folders to the Favorites list, as well as removing them from this list.

Removing a folder from Favorites

To remove a folder from the “Favorites” list, you just need to move the mouse cursor to the desired folder and click on the right mouse button. IN context menu you need to select “Delete” and after that the folder will be deleted from this list.

Adding a folder to Favorites

To add a new folder to Favorites, you must first open File Explorer. Then you need to select the desired folder and simply drag it, while holding down the mouse button, into the Explorer window into the “Favorites” list. In this case, the inscription “Create a link to Favorites” will be visible next to the dragged folder.

You can add a folder in another way. To do this, you need to open Explorer, and then in the Explorer window, open the folder that you want to add to the Favorites list. In this image, the CD-DVD folder is selected.

After that, it appears in “Favorites” new folder, in the example given - the “CD-DVD” folder.

Recovery deleted folders to Favorites

After removing the default folder links, you can restore them. To do this, right-click on “Favorites”, and then select “Restore Favorite Links” from the context menu.

Deleted links to folders that were set to Favorites by default will be restored. This action will not affect previously added folders to Favorites; links to these folders will remain in the Favorites list.

Adding programs to Favorites

Using the methods described above, you cannot add program shortcuts to Favorites. When you try to move a program shortcut to “Favorites”, the message “Could not be placed in “Favorites”” appears.

You can work around this obstacle by opening the Links folder, which contains the contents of the Favorites list.

If the program that you need to add to “Favorites” does not have a shortcut, then you need to create a shortcut for this program and send it to the Desktop.

A shortcut for a program is created in this way - “Start” menu => “All programs” => Select the program and right-click on it => in the context menu select “Create shortcut” => “You cannot create a shortcut in this folder. Should I put it on my desktop?” => “Yes.” Now the shortcut for the selected program is placed in the Desktop folder.

After the folder with the program shortcut has been opened in Explorer or the shortcut of the selected program is on the Desktop, you need to open the Start menu and open your personal folder (the name of your user folder) in the very top right corner. The contents of the Favorites list are located in the Links folder.

Open File Explorer, and then drag a program shortcut to the Links folder from the folder that contains the shortcut for the selected program. If the shortcut for the selected program is on the Desktop, then simply drag the shortcut to the “Links” folder.

In the image I dragged the label Skype programs to the "Links" folder, and immediately after that the "Skype" shortcut appeared in the "Favorites" list. In the Favorites list, program shortcuts are displayed without an arrow.

Adding files to Favorites

This is exactly how you can add to your Favorites list. separate files. First you need to select a file that will be placed in the “Favorites” list.

For example, I chose " Word document" with the name "Questions". You will need to right-click on the selected file and select “Create shortcut” in the context menu.

Before moving a file shortcut, you can remove the ending “Shortcut” from the file shortcut so that the shortcut name does not differ from the file name. This way the label will simply look more beautiful.

To do this, right-click on the shortcut, and in the context menu select “Rename”, and then remove unnecessary words from the name of the file shortcut.

After these steps, you need to open the “Links” folder, to do this you need to follow this path - “Start” menu => “Open a personal folder” => “Links”.

Now drag the file's shortcut from the folder it's currently in to the open Links folder. Immediately after this, a shortcut to the Questions file appears in the Favorites list.

In order to remove added programs and files from the Favorites list, you need to move the mouse cursor over the selected file and select “Delete” in the context menu.

Conclusions of the article

If necessary, the user can add files and folders to the Favorites list Windows Explorer. If a program or file is not needed in your favorites, you can remove it from there.

Hello. Let's talk about how to make a link or button to add to favorites (bookmarks) for all browsers: Chrome, Firefox, Opera, Internet Explorer, Safari - cross-browser, so that when the user clicks on it, he can save it for the future and remember your page. Naturally, make sure that the content is interesting, otherwise no one will bookmark it :)
So, let's go.

What to add to HTML Add to bookmarks

Enter the code in any place you need. All settings except those listed below can be changed or deleted.

  • id="fav"
    Instructions for Chrome, Opera and all browsers based on the Webkit engine will be written here
  • rel="sidebar"
    The attribute is required, needed for Firefox, so it will determine that the page via the link should be sent to favorites
  • href=""
    It is also advisable to leave it unchanged. Firefox will take the bookmark link from this address

    If it were up to me, I would replace a with span , but this option will not work with Firefox

  • onclick="addFav()"
    The javascript script will be defined here. More about him
Things to Add to JavaScript // Function to Bookmark Favorites | https://site?p=710 function addFav() ( var title = document.title, url = document.location, UA = navigator.userAgent.toLowerCase(), isFF = UA.indexOf("firefox") != - 1, isMac = UA.indexOf("mac") != -1, isWebkit = UA.indexOf("webkit") != -1, isIE = UA.indexOf(".net") != -1; (isIE || isFF) && window.external) ( // IE, Firefox window.external.AddFavorite(url, title); return false; ) if (isMac || isWebkit) ( // Webkit (Chrome, Opera), Mac document.getElementById("AddFavViaSheens").innerHTML = "Press "" + (isMac ? "Command/Cmd" : "Ctrl") + " + D" to bookmark this page"; return false;

Either put the code in external file, or place it in any place you like on the page, for example, in a section or before the closing tag
The code is commented out, I think there is nothing complicated. If you have any questions, ask in the comments.

How to avoid showing the favorites link on tablets and mobile browsers

Of course, there is no point in showing a link to add to favorites on mobile devices, she won't work there. Therefore, you need to filter them out.
To do this, you can, for example, generate a link with using javascript, and it already filters everything as needed

// Function for determining the "mobility" of the browser function MobileDetect() ( var UA = navigator.userAgent.toLowerCase(); return (/android|webos|iris|bolt|mobile|iphone|ipad|ipod|iemobile|blackberry|windows phone |opera mobi|opera mini/i .test(UA)) ? true: false ; ) // If the browser is NOT mobile, display the link if (!MobileDetect())( document.getElementById("MyID").innerHTML = "Here HTML link code (see above)"; )

Let's break it down a little

  • var UA = navigator.userAgent.toLowerCase(); — writes browser headers to a variable, converting them to lowercase. Based on its content, we will determine the “mobility” of the browser.
  • return (/Regular expression/.test(UA) ? true: false) - filter. IN regular expression fragments are recorded, which may be in the headers mobile browsers. You can add your own values ​​by separating them | .

    The filter is case sensitive. Therefore, if you enter your values ​​into the filter, be sure to write them in lowercase (small letters).

  • document.getElementById("MyID").innerHTML = "Here is the HTML code for the link"; — looks for a tag with id="MyID" in the code and writes our link instead. For it to work, you must first write down in the place where to display the link
Example of a finished script and page

Let me summarize what it might look like in the end html code

// Function for determining the "mobility" of the browser function MobileDetect() ( var UA = navigator.userAgent.toLowerCase(); return (/android|webos|iris|bolt|mobile|iphone|ipad|ipod|iemobile|blackberry|windows phone |opera mobi|opera mini/i .test(UA)) ? true: false; ) // If the browser is NOT mobile, display the link if (!MobileDetect()) ( document.getElementById("AddFavViaSheens").innerHTML = "Add to bookmarks"; ) // Function for adding favorites to bookmarks | https://site?p=710 document.getElementById("AddFavViaSheens").onclick = function () ( var title = document.title, url = document.location, UA = navigator.userAgent.toLowerCase(), isFF = UA .indexOf("firefox") != -1, isMac = UA.indexOf("mac") != -1, isWebkit = UA.indexOf("webkit") != -1, isIE = UA.indexOf(". net") != -1; if ((isIE || isFF) && window.external) ( // IE, Firefox window.external.AddFavorite(url, title); return false; ) if (isMac || isWebkit) ( // Webkit (Chrome, Opera), Mac document.getElementById("AddFavViaSheens").innerHTML = "Press "" + (isMac ? "Command/Cmd" : "Ctrl") + " + D" to bookmark the page" ; return false;

This method current for 2017. It is possible that over time, new versions of browsers will make their own adjustments, and the script will stop working. If you notice such failures, write in the comments, we will review and update the code.

In any of modern browsers There is a function to add sites to your favorites list. In this way, the user can save favorite sites and keep them always at hand in order to have access to them quick access. But for a long time The "Add to Favorites" button for the site was popular. This function somewhat simplifies the process of adding a site to bookmarks and allows you to once again remind the user that it would be a good idea to add the site to favorites.

Psychology is at work here. The fact is that when a user sees an offer to add to favorites on a website, the user wonders whether he needs it. And if he decides that the site is really useful, he will add it to his list of bookmarks. And if there is no offer, the user will not even think about this issue. That is why it is necessary to offer: whoever knocks, the door is opened.

Of course, most visitors bookmark pages not because they plan to return to the site every day, but “just in case they need it,” and, as a rule, do not return. But some users return regularly and form the core of visitors. One way or another, if people return to the site, it means that your site is useful, and this will have a positive impact on behavioral factors your resource, which will allow search engines treat him with great confidence.

You need to place the “Add to Favorites” button on your website in a visible place, but not too intrusively. The best place for such a button is the header or the side of the site.

There is no need to make the button too huge or too small. Remember that the button should fit into the overall design of the site, and not be too intrusive or too inconspicuous.

Code for the "Add site to favorites" button

Most modern browsers, with the advent of the HTML5 standard, support the rel="sidebar" attribute.

Adding a site to your favorites - "Nubex" function addSite() ( if (document.all) window.external.addFavorite("http://site", "Site builder "Nubex""); )

Don't forget to bookmark our site! (For browser Google Chrome press Ctrl+D)

Add site to favorites

But remember that in Google browser Chrome is unable to bookmark a site using a button on the site. There is a special key combination for this: Ctrl+D, so be sure to inform the user about this.

You can track the number of users who have bookmarked your site, for example, using the Yandex.Metrica service (“Attendance” - “Conversions”).

From today I will tell you about one useful function on the site - this is a link, or a button “Add to bookmarks (favorites)”. This feature allows users to bookmark a page they like on your site in their browser so they can quickly and easily access it when needed.

Many of you will say: “Why duplicate the browser function, because this button is in the address bar?”

Yes, there is, but it is there, firstly, not very noticeable, and secondly, some users do not know about it at all.

To improve the UI (user interface), it is better to duplicate this function and place the link/button “Add to bookmarks (favorites)” in a prominent place. For example, if you have an online store, then it is better to insert it on the product card; if you have a blog, then under or above the article. The location still needs to be tested. It can also be placed in the site header on all pages.

There are many different ways to implement this function on the Internet, but most of them do not work in all browsers, sometimes it doesn’t work in old ones, sometimes in new ones, sometimes in IE, sometimes somewhere else.

Therefore, I had to choose the best one among them and add a little to it. And today I will share this method with you and provide step by step instructions for installing a link/button “Add to bookmarks (favorites)” on your website.

In order to make a “add to bookmarks” button for a site, we need to follow 3 simple steps:

Creating a JS File

If you have javascript on your site - a file that connects on all pages of the site, then use it and proceed to the next step. If you don't have such a file, you need to create it. To do this, we will create a folder called “js” in the root folder of the site, and there will already be a file in it and call it “functions.js”.

< !DOCTYPE html>Store Header > Page Content

Copying and saving code

Below is the JavaScript code that you need to paste into the file you selected/created and save it:

Function addFavorite(a) ( var title = document.title; var url = document.location; try ( // Internet Explorer window.external.AddFavorite(url, title); ) catch (e) ( try ( // Mozilla window. sidebar.addPanel(title, url, ""); catch (e) ( // Opera if (typeof(opera)=="object" || window.sidebar) ( a.rel="sidebar"; a.title =title; a.url=url; return true; else ( // Unknown alert("Press Ctrl-D to bookmark the page"); ) ) return false;

Adding a link/button to the site

Now all we have to do is select a place on the site and paste the following HTML code there:

Add this page to your favorites!

That's it! You can see (and try) how it all works just below, as well as in the sidebar of this site.

P.S. I would like to add: This method works in the following browsers:

  • Opera
  • Mozilla FireFox
  • Google Chrome / Safari - the message “Press Ctrl-D to bookmark this page” will be displayed; in these browsers this function is disabled for security reasons.

Close