Google Chrome extension learning-add bookmarks

Source: Internet
Author: User

Today, we made a simple Chrome browser extension: Adding bookmarks!

 

It is to add a folder in the bookmarks manager, but, but, like the example in the official document...

 

Even if you want to name the rule, you have a method named addbk (). For details, add bookmark ^_^.

 

Why can't the results work? The browser didn't respond. What about why?

 

Finally, I finally figured out that this method cannot be named. Change the name and add "1"-> addbk1 ()!

 

OK! Oh mygad!

 

I think it should be because Chrome has occupied the method name, or it is still another reason. I don't even know,

 

Well, write down this question first and study it later!

 

The Code is as follows:

 

Function addbk1 () {<br/> alert ("hello-1"); <br/> chrome. bookmarks. create (<br/> {'parentid': '1', 'title': 'ligybook'}, <br/> function (newfolder) {<br/> alert ("hello-2"); <br/>}< br/>); <br/>} 

 

After reading the official documentation, I just don't understand what should I write the parendid value? Of course, it is the ID of the parent node ^_^

 

How can I find the ID of the parent node! Should I use Chrome. bookmarks. Search () to query it based on the bookmarks' name and obtain its ID !? It's hard to die, sorry...

 

Hey, you can see that in the code above, parentid is assigned "1", and "1" is what the magic horse means?

 

"1" represents the first node in all the top-level contacts in the bookmarks manager.

"2" is definitely the second node in all the top-level contacts in the bookmarks manager.

And so on!

 

As for saving bookmarks in the third node of the first layer, you should use Chrome. bookmarks. Search () to find them!

More concise methods are to be studied!

 

Over!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.