Search code examples
javajavascriptvaadinbookmarks

Make browser bookmark my link?


I have a vaadin button. When I click that button I want my browser (firefox) to bookmark a link, lets say www.google.com.

I didn't find much help online. I found an navigator addon but it doesn't show how to bookmark. https://vaadin.com/directory#addon/navigator

I did spot some Javascript solutions: How do I add an "Add to Favorites" button or link on my website? , Cross-browser bookmark/add to favorites javascript?

Is java script an option here?

How can I acheive this?


Solution

  • From Vaadin you can execute any javascript code you wish. In the book of vaadin there is a example on how to acomplish it.

    In short you can execute any JS code with this method:

    // Shorthand
    JavaScript.getCurrent().execute("alert('Hello')");
    

    Of course you will need to find the correct JS code to bookmark your page. If you wish to bookmark a specific application state/view, then you can use the Navigator for this. (It basically adds a #SomeState to your URL which you can the later come back)