Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create an HTML link to a file in another port? [duplicate]

Tags:

html

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?

like image 755
MaiaVictor Avatar asked Mar 05 '13 03:03

MaiaVictor


People also ask

How do I create a link to a folder in HTML?

html in your directories, you can make links to these pages by just linking to the directory name. Your browser will always pick up index as the main page for that folder. This means you can condense href="folder/index. html" into href="folder/" .

What HTML snippet is used to render a link to a separate part of the same page labeled?

You use the <a> tag, alongside its href attribute, to link to a specific part(s) on the same web page in combination with the id attribute.


1 Answers

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.

like image 57
Philip Kirkbride Avatar answered Sep 30 '22 01:09

Philip Kirkbride