That's because this isn't a full URL:
www.teladocc.com
It's a relative URL. The browser has no way of knowing the difference between www.teladocc.com and, say, index.html.
If you did this:
window.open('index.html')
Then you wouldn't really expect to go to http://index.html, would you?
Use a fully-qualified URL:
window.open('http://www.teladocc.com/pnc')
Answer from David on Stack OverflowModernized version of window.open() API
Open url in new tab with serverside javescript window.open is not working | OutSystems
Using Javascript Window.open - Stack Overflow
Open URL in new window with JavaScript - Stack Overflow
Videos
That's because this isn't a full URL:
www.teladocc.com
It's a relative URL. The browser has no way of knowing the difference between www.teladocc.com and, say, index.html.
If you did this:
window.open('index.html')
Then you wouldn't really expect to go to http://index.html, would you?
Use a fully-qualified URL:
window.open('http://www.teladocc.com/pnc')
You can add the http protocol to the url, like this:
&TeledoccLogo = "<a onclick=""javascript:window.open('http://www.teladocc.com/pnc');iAddClickStat('Benefits_Teladocc_Link');return false;"" href='#'>
Use window.open():
<a onclick="window.open(document.URL, '_blank', 'location=yes,height=570,width=520,scrollbars=yes,status=yes');">
Share Page
</a>
This will create a link titled Share Page which opens the current url in a new window with a height of 570 and width of 520.
Just use window.open() function? The third parameter lets you specify window size.
Example
var strWindowFeatures = "location=yes,height=570,width=520,scrollbars=yes,status=yes";
var URL = "https://www.linkedin.com/cws/share?mini=true&url=" + location.href;
var win = window.open(URL, "_blank", strWindowFeatures);
Specify window "features" to the open call:
window.open(url, windowName, "height=200,width=200");
When you specify a width/height, it will open it in a new window instead of a tab.
See https://developer.mozilla.org/en-US/docs/Web/API/Window.open#Position_and_size_features for all the possible features.
You don't need to use height, just make sure you use _blank, Without it, it opens in a new tab.
For a empty window:
window.open('', '_blank', 'toolbar=0,location=0,menubar=0');
For a specific URL:
window.open('http://www.google.com', '_blank', 'toolbar=0,location=0,menubar=0');
Here at work, we do a fair bit of surveys on various sites via Survey Monkey. The MO has always been to do a pop under window - focus the parent, not the child/new window. I've stressed how I think this is slimey (hiding the new window), but it is what it is and that's that :)
Seems every time we have a survey, I'll get people coming to me because the new window is getting blocked by someone. I've looked at the code they're using and it's using the typical window.onload event. I tell them this is probably why they're getting blocked as the pop up blockers are no doubt seeing automatically opened windows as unwanted advertising. Because the window onload and onunload events have been so abused, this is why we have pop up blockers built into browsers as well as plugins.
I thought about perhaps using a timer to delay execution of the pop up from onload, but not sure if this will make any difference. I'm kind of guessing not but I haven't tested it yet. I can't really test it as it's another dept. that has access to the server, not me... I've also thought about using onmousemove to trigger it (user-triggered event) and then nulling that out but that seems even more stupid.
I've suggested adding static survey promos which would be user-triggered events as I think those might fare better in the world of pop up blockers - even though there's still no guarantee. So the user clicks to pop the new window.
I've also suggested removing JS from the equation altogether and having the promos link straight to Survey Monkey. The counter there is that they've lost where they are in our site (they could have deep-linked in). They can't just easily close the Survey Monkey window to pick back up where they left off in their task. Off the top of my head, I don't know if they can use their back button to backtrack from the end of the Survey Monkey survey, either.
Is there a general consensus of best practices in regards to opening a new pop up (or pop under) window with JavaScript with pop up blockers?