AddThis email button - javascript

Using the AddThis plugin (http://www.addthis.com/) I am using the code below to put an email button on my website. But despite setting the target="_blank" it still opens a new tab rather than window. So I am wondering if there is a way to make it open up in a new browser window and not a tab.
<a target="_blank" href="http://api.addthis.com/oexchange/0.8/forward/email/offer? url=${siteURL}/${ourURL}&title=${addThisEmailTitle}" rel="nofollow"><img border="none" src="http://cache.addthiscdn.com/icons/v1/thumbs/email.gif"></img></a>

It all depends on the user and his or her browser defaults.
For example in Chrome target="_blank" opens in a new tab.

The target attribute doesn't help you. AddThis uses a modal pop-up to open the e-mail and other share services (eg. Pinterest). You can use the Addthis Sharing Endpoints that doesn't uses their script and make it work how you want.

Related

Is there a way to link to the browser's (for example Chrome) "new tab" page?

I want to create a button that when clicked, opens the "New tab" page. the page that suggests your most visited websites or is customized by you. In chrome it is accessible by typing "chrome://new-tab-page" in the address bar. How can I link to that?
You could use target="_blank" to open a new tab
Visit W3Schools!
read more here

Opening an external website in a new tab/window/popup

I know that clicking on:
Click here
would quit the current page and go to this address, and that
Click here
would open it in a new tab (default behaviour in Chrome and Firefox).
But how to have a button such that clicking on it would open the external website in a new browser window, possibly 700x500px? (like if you do New window in Chrome menu)
You cannot do that with pure HTML - to achieve the result you need JavaScript.
<a href="http://www.example.com" onclick="window.open('http://www.example.com',
'newwindow',
'width=700,height=500');
return false;">Click here</a>
However, this solution is vulnerable to be pop-up blocked.
As #Rob M. suggested, here you can read everything about window.open().

Cannot open page in a new tab using location.href

I need to use window.location.href to open the user's email so for that I have the following code:
$("#email").click(function(){
window.location.href = "mailto:myemail.com?subject=Subject&body=xxxxxxxxxxxxxxxxxxxxxxxxxxx";
});
Which works fine. However, the problem is I cannot open the user email page in a new tab and it opens by redirecting the current page which is not user friendly. How can I achieve this?
You can use the target="_blank" attribute on any regular anchor tag to make sure that the link is opened in a new tab, without using any JavaScript. Note, however, that mailto links are often handled by browsers specially and may just redirect to the system's default mail app without opening a visible tab.
<a id="email" target="_blank" href="mailto:person#example.com?subject=Subject&body=Body">
Email us!
</a>
Edit: It looks as if this method won't work in certain versions of Firefox, due to a bug. (See this answer.)
You're looking for window.open()
Example:
window.open("mailto:myemail.com?subject=Subject&body=xxxxxxxxxxxxxxxxxxxxxxxxxxx");
Have a look at this:
Open the href mailto link in new tab / window
You can't open a 'mailto' link in new tab/window by default.
You need to use window.open() in your click override.
please check below link and you can view the demo using this link.
https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_win_open

How to open a link in new window with tab enabled

I search a lot but could not figured it out.
Is it possible to open a new window with tab enabled using window.open() method?.
The way chrome context menu "open link in new window" works.
The browser decides on its own how links will open. Sometimes a user can configure how links are to be opened, but the web page cannot do this.
using an anchor tag you can set the target attribute to have some control over where the link opens. Other than that, this behavior is up to the browser and user and cannot be controlled by javascript.
Use this code
window.open("http:.//www.google.com","DemoName",'scrollbars=1,height=650,width=1050');

Open url in new tab using javascript without click an anchor

i read a lot of solutions but all of them are clicking a url, and it works, but my client ask me to do is users opens his website, it automatically open a new tab with some special offers , so my question, is there any way to open a new tab without any user intervention? , maybe a jquery plugin?, i know the tabs rely on the web browser, but it have to be a way, a lot of web pages does it,but how?
Greetings
Without modifying the configuration of browser, the answer is no, only trusted event can open a new window (or tab)
You may ask if your client could change their browser's configuration to allow a popup window from an untrusted javascript program.
Write script in your page to open new page:
<script>
window.open("specialOffers.aspx");
</script>
and in the "specialOffers.aspx" page in the tag write:
<base target="_blank"/>

Categories

Resources