Create a Gmail share link - javascript

I would like to put a button on my one page web application that allows a user to send a link through Gmail. I found that some websites such as addthis.com provide such a button, however this button automatically uses the link from the url bar. Since I have a one page web application the link in the url bar will always be the same. I need to be able to to put the link in the button myself (which is possible with, for example, the Facebook and Twitter share buttons).
How can I create a Gmail button that can be used to share a link?
Thank you.

On Button click write a function and do this inside the function
let url = 'https://mail.google.com/mail/?view=cm&fs=1&tf=1&to=&su=Your+Subject+here&body='+msgbody+'&ui=2&tf=1&pli=1';
window.open(url, 'sharer', 'toolbar=0,status=0,width=648,height=395');
The url will generate a link to open a gmail tab with auto filled subject and in in place of msgbody you can put your url you want to share.

Gmail Sharable Link Creator
Site Link: GmailLink.GitHub.io
Steps to Follow to generate the Link
Get the Message ID Of Mail Thread (Mail > 3 dot menu in Right side (⋮) > Click on Show Original > See the MessageID).
Copy the Message-Id
Use the MessageId & click On Submit to generate the Mail Sharable Link.

Try the official Google+ Share button. There's a field there where you'll specify the "URL to share". Since you're only using one URL, this might work in your favor.

Related

Facebook share button current URL

I want to add a share button to my website but notice I have two similar options:
Share button
Share dialog
Are they different and how could I show a share button for the dialog option?
Also, for the button code it says HTML5/data-href "defaults to the current URL" which I want, so would I simply delete data-href from the button code or just leave the URL empty?
Share Button
Social Plugin that comes with a predefined button, you cannot change the appearance. Simple to include.
Share Dialog
Use your own button/link/whatever and call FB.ui to open the Dialog.

How to open a webpage in the same tab upon clicking a link in the mail

I want to open a webpage in the same tab by clicking a link from email.
So, If the webpage is already open in a tab, By clicking the link in email should not open another tab but should use the same tab to render the webpage.
For example - if https://example.com/index.html is already open in a tab, By clicking https://example.com/index.html link from email should not open another tab but should open the application in the same tab.
I understand, we can do this programatically using Javascript like window.open("https://example.com/index.html","_self") but is there a way to form the URL to be used in email to open the webpage to accomplish this?
Thanks
No, it is not technically possible. There are no ways to send this type of instructions from an email client to the browser.
Moreover, javascript is not allowed in emails.
Use target="_self" in a page
The Link
From an email... not possible, because the email client has no idea in what tab the standard browser is
This is not possible for links in e-mails. Usually, the mail service provider is set to open it in a new tab so that the user is still connected.

Mask or hide an affiliate URL?

I would like to share an affiliate link that points to an iOS app in Apple's Appstore. Is it possible to mask it or create a sort of proxy to it, in a way that another user can not access it directly while at the same time maintaining its function as an affiliate link?
Its not possible to completely hide it, but it would be possible to hide the url from non-technical users using a few tricks.
You can put an onclick event handler on the link instead of an href attribute so that the user cannot get the URL by right-clicking the link.
Here's a sample code at jsfiddle.

Javascript Grab URL and insert into Pinterest button for Facebook Page Tab App

I am trying to add a Pinterest button onto a product page for a single image in a Facebook Tab app.
The Pinterest code is grabbed from their goodies section, and must include a URL, the Media URL and the Description.
I am not that proficient with Javascript. I am trying to pull the URL and insert into the Javascript button for a single item. Please see below; Thanks.
Pin It
Since you trying to get Pinterest button working in Facebook Page tab this will not work due to inability to know which Page you're on in JavaScript.
This info is passed to server with signed_request. You have couple of options to do so:
Build the link to page that will be linked to "Pin" server-side
Pass information about Page and Page Tab to client side and build the link here.
Beware that this is just a link and it will not looks like Pin-It button until you including Pinterest JavaScript (//assets.pinterest.com/js/pinit.js) on a page. If you build that link in Client Side you must include that JavaScript after, so link will be replaced by iframe with actual Pin-It button.

Open redirect page in new tab and reopen in the same tab on multiple redirects Django

I am making a blog app in Django and I want to do the following things
When the user submits the preview button I want to open the partially completed blog in a new tab in the same window.
Secondly if the user does not close the tab and again presses preview button, I want to display the updated blog in the tab which was previously opened.
How can I do this?
Edit:
As told in the answer below I am trying to use this code snippet to open it in a new window, but this does not work
<script>
var current_link = $(location).attr('href');
$('.preview_button').onClick(function() {
window.open(current_link,'preview_tab');
});
</script>
Also I currently have 3 submit buttons and I want to provide this feature only for 1 submit button i.e. preview So I cannot directly do (#form).onSubmit. For the the other two buttons, one updates the content via Ajax and the other redirects to a new page.
Try using a Javascript onSubmit to open the appropriate preview page with window.open, passing a name as the second parameter. It does almost exactly that. (If you want to support having different preview tabs associated with different editing tabs, include something in the name based on a tab ID of some kind -- maybe the article ID plus a random number, or something.)
You'll have to also send the updated content into the server via AJAX.

Categories