Overview
For some websites, let the User a button to add a page to the collection of the design is very good, it can remind users to add Web pages to favorites, thereby increasing the user's return rate, so that the site to obtain more traffic.
On the PC side, only IE and FF support the use of JS to add Web pages to the collection of operations, on the mobile side currently do not support the Web to add favorites, in addition to UC Mobile browser, because the UC mobile browser with the U4 kernel , after some processing.
Because the number of users of UC browser is still quite a lot of, so it is necessary to explore how the UC mobile browser side to add a Web page to Favorites , I recorded the results for later development of reference.
Results
Directly on the result , the following code will bring up the browser's Favorites menu:
window.location.href = "ext:add_favorite";
The following steps can be used to facilitate testing:
- Open the UC Browser, enter a Web site, and enter the site.
- Enter Ext:add_favorite in the Address bar and click Enter.
- This will appear in the Favorites menu!
So for one-click Favorites, just use JQ to bind a fixed-point event on a single button:
$('.button').on('click', function() { window.location.href = "ext:add_favorite";})
The cool shadow mode of UC
The general Web site will launch the UC cool shadow mode , the PC-side code into the mobile code, and will automatically add "click the Favorite" button. Detailed reference: Cool shadow mode.
It is worth mentioning that only the site with the max Program (MAXCMS) template , UC will start the cool shadow mode. After entering the cool shadow mode, UC will automatically load the website wapmaxcms_ad_filter.min.js, this JS inside has to join the collection of implementation, I was in this JS inside.
PWA for UC
Surprisingly, the UC U4 2.0 kernel implements PWA, specifically for reference: U4 2.0 new features--add to the small screen inside the to Home screens .
Developer tools for UC
You can go to UC Plus to download the UC Browser developer version and the UC Browser developer Tool to debug the UC page.
Operation Method:
- Phone installs UC Browser developer version , PC installs UC Browser developer Tool .
- The phone turns on USB debugging .
- Connect your phone to your computer using USB.
- Your computer's UC Browser developer tool will automatically recognize it, then the authorization box will pop up on your phone and click Confirm .
Add favorite code to PC side
<script type="text/javascript">function addFavorite(){ var bookmarkUrl = "http://baidu.com"; var bookmarkTitle = "baidu"; if (window.sidebar) { // For Mozilla Firefox Bookmark window.sidebar.addPanel(bookmarkTitle, bookmarkUrl,""); } else if( window.external || document.all) { // For IE Favorite window.external.AddFavorite( bookmarkUrl, bookmarkTitle); } else { // for other browsers which does not support alert('浏览器不支持,请按 Ctrl+D 手动收藏!'); return false; }}</script><a href="#" rel="sidebar" onclick="addFavorite()">加入收藏</a>
Specific reference: Compatible with most browser JS add favorite script
UC Mobile Browser JS add to Favorite folder