Search code examples
javascriptbookmarklet

Use Bookmarklet to display confirmation, then continue based on response


I wish to make a Bookmarklet in order to remove some recurring steps in a workplace. We have analysts who find breaking stories on the net and send them as quick alerts internally via email.

I have made this a bit faster by creating the below bookmarklet but for now it only sends an email.

What i'm looking for in the end would be how to do the following when they Click

  1. Display the Title and URL to the user in a confirmation Form
  2. If the user clicks yes, then perform a function such as editing the Title/URL slightly and then sending the email.
  3. Do this by calling a .js on our server so the code is all centralised

Would someone have insight plz.

The bookmarklet <a href="javascript:(function()%7Bvar%20bcc%20%3D%20%22email.com%22%3Bvar%20subject%20%3D%20%22News%20Alert%20%2F%20Alerte%20Nouvelles%3A%20%22%20%2B%20document.title%3Bvar%20title%20%3D%20document.title%20%2B%20%22%5Cn%22%3Bvar%20url%20%3D%20%20window.location.href%3Bwindow.location.href%20%3D%20%22mailto%3A%3Fbcc%3D%22%2Bbcc%2B%22%26subject%3D%22%2Bsubject%2B%22%26body%3D%22%2BencodeURIComponent(title)%20%2B%20encodeURIComponent(url)%7D)()">


Solution

  • For future reference, this is what I did.

    javascript:(function(){var a=window,b=a.open("http://websiteurl/en/administration/bookmark?url="+encodeURIComponent(location.href)+"&title="+encodeURIComponent(document.title),"ec_popup","left="+((a.screenX||a.screenLeft)+10)+",top="+((a.screenY||a.screenTop)+10)+",height=600px,width=900px,resizable=1,scrollbars=1,alwaysRaised=1");})();
    

    This form then has everything required to post an ajax call to an api.