7

The tag below ceates a link to a page without having to provide the full URL:

<a href="foo.html">link</a>

So if you click it from example.com/, you'll go to example.com/foo.html. Is there a way to create a link that'll go to example.com:port/foo.html instead?

Philip Kirkbride
  • 21,381
  • 38
  • 125
  • 225
MaiaVictor
  • 51,090
  • 44
  • 144
  • 286

1 Answers1

1

See here -> https://stackoverflow.com/a/6016361/773263

// delegate event for performance,
// and save attaching a million events to each anchor
document.addEventListener('click', function(event) {
  var target = event.target;
  if (target.tagName.toLowerCase() == 'a')
  {
      var port = target.getAttribute('href')
                       .match(/^:(\d+)$/);
      if (port)
      {
         target.port = port[1];
      }
  }
}, false);

Seems to be the best way to do it. I don't think a purely HTML solution is possible.

Community
  • 1
  • 1
Philip Kirkbride
  • 21,381
  • 38
  • 125
  • 225