Relative Path, but for Port?

Nyxynyx picture Nyxynyx · Nov 29, 2011 · Viewed 15.3k times · Source

We are all familiar with relative paths: A relative path to ./images/hello.jpg from http://www.domain.com/hey links to http://www.domain.com/hey/images/hello.jpg.

Problem: How do you state a relative path to http://www.domain.com:1234 when you are at http://www.domain.com/hey?

Answer

peterp picture peterp · Nov 29, 2011

This can be achieved using JavaScript by setting the window.location.port property.

<a href="#" onclick="javascript:window.location.port=8080">go</a>