The translation was generated automatically and may contain mistakes

Закладки

A widget to add a page to bookmarks will make your site closer and more accessible to the user. To add a page to the bookmarking block, visitors will not have to leave your resource: saving the necessary materials will take only a moment and will not require additional confirmations - often this is much faster than switching to a new page.

Widget connection

To add a VKontakte bookmark widget to your site, follow these steps:

Step 1. In the tag <head> On your website, add a link. openapi.js :

HTML
<script src="https://vk.com/js/api/openapi.js?169" type="text/javascript"></script>

Step 2. Add an element to the body of the page <div> , which will display comments, give it a unique id, and add a widget initialization code to it. For example:

HTML
<div id="vk_recommend"></div> <script type="text/javascript"> VK.Widgets.Recommended('vk_recommend'); </script>

If your website is already in use Open API , adding a widget is even easier. Simply add widget initialization.

Additional settings

Method VK.Widgets.Bookmarks It takes parameters:

  • element_id ( string ), the mandatory parameter is the id of the element that will be the button container for adding a page to bookmarks. Our default constructor uses a value vk_bookmarks .
  • options ( object ) — block options with widget. An object that can contain fields:
    • url ( string URL of the page, the link to which will be added to bookmarks from this widget. By default, the URL of the current page.
    • height ( integer The height of the block in pixels. Possible values: 18 , 20 , 22 , 24 , 30 . By default: 24 .

Example of use

HTML
<div id="vk_bookmarks"></div> <script type="text/javascript"> VK.Widgets.Bookmarks('vk_bookmarks', { url: "https://dev.vk.com/widgets/bookmarks" }); </script>

Код виджета

To add a widget to your site, simply copy the code to paste to the page you want to place the widget on.

Button height
Code for embedding widget on website
HTML
<!-- Put this script tag to the <head> of your page --> <script type="text/javascript" src="https://vk.ru/js/api/openapi.js?168" charset="windows-1251" ></script> <!-- Put this script tag to the place, where the Bookmarks block will be --> <div id="vk_bookmarks"></div> <script type="text/javascript"> VK.Widgets.Bookmarks("vk_bookmarks", {}); </script>