gmail compose box not opened with subject and content using JS - javascript

The js window.open does not open the IOS compose box, but in android, browser works fine subject and the content is appended.
code:
window.open("https://mail.google.com/mail/?view=cm&fs=1&tf=1&mailto=sri#gmail.com&su=" + 'subject' + "&body=" + 'body' + "&ui=2&tf=1&pli=1", 'sharer', 'toolbar=0,status=0,width=648,height=395');
how to open the Gmail compose box with the subject and content of the mail for all browser compatibility

Related

Drag&drop text to gas web application's iframe

I'm coding an google app script which grab selected text as parameter and open new window via a bookmarklet. I'm trying select&drag&drop some text or link to web application input/textarea which works on opened window example: https://script.google.com/macros/s/.../exec?article=.
The problem is when I allow iframe with .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL) and add https://script.google.com/macros/s/.../exec?article= page in an iframe instead of opening in a new page; drag&dropping text became disabled. Is there anyway to enable drag&drop text to iframe's input box?
drag&drop is available in normal https://script.google.com/macros/s/.../exec?article= page but not in an iframe.
Also thanks to comments I tried it on Firefox and it works, but still not on Chrome
GAS
function doGet(e) {
return HtmlService.createHtmlOutput('')
.append('<input type="text" id="kind" placeholder="Kind" size="4" value="' + (e.parameter.article?e.parameter.article:"") + '">')
.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
Logger.log(e);
}
Bookmarklet opening new page
javascript:if(window.getSelection)s=window.getSelection(); else if(document.getSelection)s=document.getSelection(); else if(document.selection)s=document.selection.createRange().text; open('https://script.google.com/macros/s/...GAS.ID.../exec?article=article'+(location.host=='scholar.google.com'?'':'&pdf='+encodeURIComponent(location.href))+'&bib='+encodeURIComponent(s.toString())+'bib');0
Bookmarklet adding iframe
javascript:if(window.getSelection)s=window.getSelection();else if(document.getSelection)s=document.getSelection();else if(document.selection)s=document.selection.createRange().text; iframe=document.body.appendChild(document.createElement('iframe'));iframe.style='position:fixed;bottom:0;z-index:99999;width:280px;'; iframe.src='https://script.google.com/macros/s/...GAS.ID.../exec?article=article'+(location.host=='scholar.google.com'?'':'&pdf='+encodeURIComponent(location.href))+'&bib='+encodeURIComponent(s.toString());0
*replace "/...GAS.ID.../" with web application id in bookmarklet

HTML/PHP Block news tabs on Android and iOS browsers

I use this code for codebar scan with cellphone, on Google Chrome works but on Firefox and Samsung Browser after scan barcode an another tab are created, and +1 tab per scan.
My code:
window.top.location.href = "zxing://scan/?ret=" + href + "profile_sps.php?barid={CODE}";
I tried several ways:
window.open("zxing://scan/?ret=http://rodrigovrodrigues.tk/sjb/profile_sps.php?barid={CODE}", "_top");
window.self.location.href = "zxing://scan/?ret=" + href + "profile_sps.php?barid={CODE}";
window.parent.location.href = "zxing://scan/?ret=" + href + "profile_sps.php?barid={CODE}";
And some others...
Any friend can help me with this?
Thanks for all help.

How to ask permision so others can open mailto

I'm trying to open mail on click in js. I'm using mailto, but in chrome you need to change the handlers settings to make it work.
My question is can I make some sort of popup that ask for persmission and changes this setting to others?
PS: to give permision for me I only found this way:
Open Gmail in Chrome and click the Protocol Handler icon overlapping-diamonds in your browser's address bar.
When prompted to "Allow Gmail to open all email links?", select "Use Gmail," and click "Done."
EDIT
My code to send the mail
$("#applyText").click(function(){
var email = 'mail#gmail.com';
var subject = 'Hire me im a genius';
var emailBody = 'Hi Sample,';
document.location = "mailto:"+email+"?
subject="+subject+"&body="+emailBody;
});
this is browser settings specific, ie. it will behave differently depending on the user's browser settings. The user can change how mailto: links behave in chrome by visiting chrome://settings/handlers, or Chrome Settings->Content Settings->Manage Handlers...
This is an answer to that question.
So to answer your question
No it is not possible because this is browser settings.
But most browsers should open it without a problem. For me this works properly.
By the way, you have some minor mistakes in your code.
Here is an working example
$("#applyText").click(function() {
var email = 'mail#gmail.com';
var subject = 'Hire me im a genius';
var emailBody = 'Hi Sample,';
document.location = "mailto:" + email + "?subject=" + subject + "&body=" + emailBody;
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="applyText">Click</button>

Internet Explorer Opening Same Page for Different URLs of same website

I have an application where i am doing new tab pop-ups in internet explorer(8,10,11) using window.open(myurl)
The pop-up triggered by a website contains a URL which is another page of that website. Problem here is that when the pop-up takes place, same webpage opens as the one from where the pop-up is being initiated.
If i copy the URL from address bar of the pop-up window and close all windows and than open that URL in new window of internet explorer only than my required page opens in the pop-up window/tab.
(Note: Same application works perfectly fine in Mozila Firefox without any issue, but it is clients requirement to run my application in IE)
Following is a method which is doing the pop-up:
function handlePhonecallScreenpop(callF, callT, callA, custid, entityN) {
var extraqs = "cf=" + callF;
extraqs += "&ct=" + callT;
extraqs += "&cd=outd";
extraqs += "&ca=" + callA;
extraqs += "&cid=" + custid;
extraqs += "&en=" + entityN;
var url = webUrl() + "/main.aspx?etn=phonecall&pagetype=entityrecord&extraqs=" + encodeURIComponent(extraqs);
window.open(url, "callpop");
}
I'm guessing that you aren't setting a target window name. Which means that you're reusing the same target window for EVERY window.open() call. Try adding an arg to each of your calls:
window.open('firsturl', 'windowA');
vs.
window.open('secondurl', 'windowB');
You should see two different windows.
If you change the name to _blank it should always open in a new window.
window.open(url, "_blank");

How to open outlook mail compose window in chrome app?

I'm working on a chrome application which needs to create an email on click of a button. I'm using mailto: for that and since default client is Outlook, it should open outlook email compose window. I'm using below code for same -
var mail = "mailto:" + recp + "?subject=" + sub;
newWindow = window.open(mail);
When this is executes, chrome app opens outlook email window but also opens a tab in chrome with url as contents of mail variable . and even if I call close on the newly created tab, that does not get closed. My goal is to create email without any additional tab.
Is there any way I could achieve this
You don't have to open new window for this link, since there will be auto-open outlook window (I have no associated action with that type of link, so I get popup to select with that program to open it)
$("span").click(function() {
var recipient = $(this).text();
window.location.href = "mailto:" + recipient + "?subject=Mail to " + recipient;
});
span {
cursor: pointer;
display: inline-block;
margin: 0 10px;
}
span:hover {
border-bottom: 1px dotted black;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span>sample#mail.com</span>
<span>another#mail.com</span>
<span>sample2#mail.com</span>

Categories