0

I am trying to code so that I use Javascript using window.open to open a url. This opens a new window as desired, BUT the url is wrong. It adds the domain url to the beginning of it. Does anyone know how I would fix this? It has to use javascript.

&TeledoccLogo = "<a onclick=""javascript:window.open('www.teladocc.com/');iAddClickStat('Benefits_Teladocc_Link');return false;"" href='#'>

URL it takes me to: https://finder-t2.int.ps.nbc.com/psp/ps/EMPLOYEE/EMPL/h/www.teladocc.com/pnc

2
  • try adding the full url with http://, teladocc.com Commented Nov 13, 2015 at 20:02
  • that is the full url. www.teladocc.com/ Commented Nov 13, 2015 at 20:02

4 Answers 4

4

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')
Sign up to request clarification or add additional context in comments.

Comments

3

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='#'>

Comments

3

Add http:// to the link in your window.open. Here's a JSFiddle demo.

This one will replace the current URL:

<button onclick="window.open('http://google.com');">Demo</button>

This one will open the URL and append:

<button onclick="window.open('google.com');">Demo 2</button>

Comments

2

You need to include the protocol in your call.

&TeledoccLogo = "<a onclick=""javascript:window.open('http://www.teladocc.com/pnc');iAddClickStat('Benefits_Teladocc_Link');return false;"" href='#'>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.