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?
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/" .
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With