I am sending an email that includes a link. When the recipient clicks that link, I'd like the resulting page to come up pop-up (rather than open in a new tab) when clicked.
I'm using Gmail as my reference mail client.
Things I've tried:
target="_blank": opens in a new tab, not a pop-up
<a onclick="window.open(...)">: stripped out by gmail.
<a href="javascript:window.open(...)">: stripped out by gmail.
opening a new tab, and then generating a pop-up from that tab via onLoad or similar: pop-up blocked.
Most popup-related online resources I've found so far have been quite out of date, but the rule of thumb appears to be "if an event is
user-initiated, it will be allowed to open a popup."
Even a partial solution (only works in Chrome/Firefox/Safari/etc) would be better than nothing.
Almost all mail clients strip out inline JavaScript because it is vector for malware.
You can only include regular links in Emails.
Related
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.
I have a link that on entering it (click/tap), is a confirmation to pay.
The link is sent by sms to the user.
The problem starts when the link is being displayed as a rich preview url, that causes the link to be visited and the user will be considerd to confirm the payment.
Just so you can get a clue as for what is a rich preview (https://richpreview.com/). It happens in messaging services like WhatsApp and iMessage when they display the content of the link before you open it. It complies to the open graph protocol explained here: http://ogp.me/
The question is: how do I disable this rich perview from my end (server side) or how do I detect that this request is for rich preview so that I could ignore the payment confirmation?
One of the suggestions from Google searches was to simply locate the url link in the middle of the text, will it work in all cases?
I had the idea of creating a new page that will redirect (by script) on render to the actual payment confirmation page, is it possible or will the rich preview run this script as well?
Thanks
Removing the http:// or https:// off the front of the link will cause Whatsapp to disable rich link previews.
Unfortunately, using redirects probably won't work. Pretty much, what the rich link does, is it opens its own mini web browser and opens the page for you. If you have redirects the app will just follow these.
Before sending the link, make the server put a dot and a space before the link and a space and a dot after it. See the example:
Sending a the link like this (http://www.bbc.co.uk/news/uk-40909057) will produce a rich link, like this:
However, if you send the same link, just with the dots
(. http://www.bbc.co.uk/news/uk-40909057 .) it does this:
Note: the messaging service removes the dots automatically when it acts upon them, so they don't appear in the message the recipient sees.
I think this should work for you, please get back to me when you have checked it.
The thing that did the trick was based upon the user agent of the request to get the preview.
All the requests for rich preview were from a non-mobile device,
since the platform is solely mobile based, the solution was to detect the user agent and "block" the automatic charge for the user with the non-mobile ua.
instead a button was presented to continue the charge procces for the cases that the device was not recognized as mobile but the proccess now continues with the user intent.
I have the following code in which I am trying to open multiple mailclient
It works in Firefox but dont work in Chrome
<button class="button">Open Email</button>
$(document).ready(function(){
$('.button').on('click',function(){
window.location.href = "mailto:user#example.com?subject=Subject&body=message%20goes%20here";
window.location.href = "mailto:user#example.com?subject=Subject2&body=message%20goes%20here";
});
});
Here is the fiddle to it
Anyone knows whats the reason behind this , or is there any other technique to do this?
Thanks
Chrome allows only one opened window per user action. If opening new browsers window was the issue, you could tell the popup blocker to allow it, but this is not possible when launching email windows. You could either require two user actions (e.g. two buttons) or you could make a web based mail form to do the same thing (if you're using the mail client of tracing purposes, just make it send a copy to yourself.
If you want to open multiple links you shouldn't use window.location.href, it opens link in current window and you cant really have more than one link opened in one window. You should use window.open(your_url) for that, but beware, it will create popup windows.
From a browser perspective mailto is a link like any other, so assigning it to window.location.href twice in a row is like fast-clicking two links in a page, browser will process only one of them.
And the last, code from your question not working even in FF if you use browser based mail client, like gmail.
You could supply 2 links for the user tp open the email clients manually, you could also open the client, refresh the page (indicating something on the url for the second one) and then open the second one?
I am creating a site which makes use of youtube videos, but I don't want to use the embedded player, I want to just have a youtube page in an IFRAME. I read the youtube TOS and I am not sure whether IFRAMES are allowed other than the embedded player so taking no chances I think I will build the site to open links in new tabs instead. What I would really like is to be able to open new links in just one tab. To clarify, my site is tab 1, once a link is clicked youtube opens in tab 2, any further links clicked on my site replace the content in tab 2, and no more than 2 tabs will exist.
YouTube and some other high-profile websites block the use of iFrame for security reasons. So if you used an iFrame, it would just load blank.
To open a link to a new tab you would use:
Open me!
I'm not entirely sure that you can control which tab to then replace with further content.
My suggestion would be to do this:
1) Create links to pages with videos embedded in them, with target="_blank".
2) When a user clicks the link, capture it with Javascript (perhaps jQuery) and open the contents of that within some kind of modal overlay like Shadowbox ( http://www.shadowbox-js.com/ ).
This way, the user stays within the same window, without the need for iFrames or new tabs at all. If the user has JS disabled, they'll then get a default "new tab" behavior.
Good luck.
I don't think you control that what you want very easily, and if you can find a hook for this, it most likely is not cross-browser. I'm open to a better suggestion but I think you could use javascript window.open(URL, windowName[, windowFeatures]) and use the same name every time you call it. Then it will replace the previous window. It just will not open in another tab but in a popup.
You cannot control a webpage in another tab and neither can you limit the no. of tabs a browser can open for obvious reasons of security. Limiting the no. of tabs that can be opened or controlling without user's intervention would definitely be considered hacking, bowsers don't allow that.
I have an application where I have tabs where each tab represent a particular sub application.
I'd like to have all links such as site.com/* to open in an already existing browser tab, and somehow possibly firing a JavaScript event that a new link was received/opened so that I could open it in my application instead.
So basically, I'm building a web application and I'd like to have links opening in the same application instance rather than creating multiple instances of my application.
Is this possible?
Update: I'm talking about if someone sends a link over Skype or email, that the links would open in my application. I'm aware of most web technologies and I can't think of any approach, that's why I left this question if someone might have an idea. Or a plugin, if not, someday we might get one and I'll add the answer my own / update question.
Yes. Just use the target attribute of the links to open them in their sub-application browsing context (i.e. tab, window).
There is no event that fires on opening links. You may add a click event handler to all links, executing what you need when the URL matches.
If you want you want your web application to open specific protocols or mime types, even that is possible with HTML5. You can use window.navigator.registerProtocolHandler() and window.navigator.registerContentHandler(). See the HTML5 Draft on Custom scheme and content handlers.
If a users opens a new tab/window for a link he received by email etc, you usually can't catch and prevent that. But you could use Cross-document messaging, e.g. window.postMessage, to look whether your app is already opened somewhere in the browser and then close one tab and focus the other.