top | item 35670325

I just learned about HTML redirects (2020)

110 points| sc90 | 2 years ago |apitman.com

81 comments

order

gbraad|2 years ago

I remember once learning that php has a `header` function and have been using 'location:...' since ever (pre-2000) as php was almost always supported by hosters like dreamhost, hostgator, and nearly every Linux install came pre-installed with Apache and the php mod. The meta htttp-equiv was a last resort (like gh-pages). Never really used the JS option unless it was part of the application.

handsclean|2 years ago

This is also used as a poor man’s live feed: just use this element to reload the page or frame on a set interval.

connordoner|2 years ago

This is one of the oldest tricks in the book and was used heavily before WebSockets and similar became mainstream.

donatj|2 years ago

Long polling HTML was popular for a while in the early aughts. Just never close the HTTP connection and stream new HTML elements onto the page. I don’t think that would get along with modern tooling.

remram|2 years ago

Also not widely known: the multipart/x-mixed-replace media type, allowing you to send multiple files and have them replace each other. A simple streaming solution without video, WebSocket, or JavaScript, just an <img>.

thiht|2 years ago

This was so annoying when you wanted to copy some text and the page kept refreshing at the wrong time

SoftTalker|2 years ago

Drudge Report site still does this, I think. Maybe it's JS now, never checked.

moltar|2 years ago

Oh my. Chat.cgi days! :D

Reptur|2 years ago

My fav was Marquee. Could put one inside the other, make one vertical, add some text and watch it bounce around like the DVD screensaver logo.

moritzwarhier|2 years ago

I remember these from when I initially taught myself HTML (4) and CSS as a kid.

It's kind of amazing how parts of the spec that seem dated or obsolete can still be useful today and are even widely used in corner cases.

RobotToaster|2 years ago

It would be nice to see a collection of "dated" or "usually forgotten" web tools like this, and how they can still be useful.

kristopolous|2 years ago

Combining it with the referrer tag and you can make some pretty interesting graphs. With frames you can even do Floyd's algorithm.

I made a demo of this about 20 years ago but I think it just confused people. One of my early flops that I thought was cool. It was all in perl and I think there was some JS in there as well but I don't remember anymore. No idea where it is now.

Rewrite it and make a hyped up pitch page. People will call you a genius and I'll pretend not to care

pooper|2 years ago

I was so sure archive.is/wip/xxxxxx used this but I just checked and it uses

<script>{setInterval(function(){document.location.reload();},5000)}</script>

now

for example, I tried out view-source:https://archive.fo/wip/RpDSg

does anyone else remember seeing meta refresh? if so, any idea why they switched to javascript reload

stuckkeys|2 years ago

Ahh. This brings back memories. I used to do this when I was using Adobe (Macromedia originally) FLASH back in the day. If no FLASH, show them the shitty version. HAHA. Good times.

MrVandemar|2 years ago

You'd be surprised how often Flash was "the shitty version" as it was almost always bloated with long load times, inaccessible content and a lot of pointless stuff that was clearly to impress the client who comissioned it, not the poor user who wanted to find something out.

GrumpyNl|2 years ago

Sometimes im flabbergasted on how the most basic html knowledge is lost on newer generations.

Puts|2 years ago

This is what you get if you learn everything by just googling exactly what you need for the moment. Reading proper books and RFCs are underrated these days.

Twisell|2 years ago

Maybe because we collectively pretty badly handled knowledge transmission between generations.

For the pioneers the most difficult part of learning CS was to get hardware needed. This mostly determined the technological stack they would then learn.

Nowadays hardware is commodity and the main problem is to determine what the hell you should start learning first because you can't learn everything it has now became humanely impossible.

I was born somewhen in the middle. Because of my first field I wish I could have mastered python. But at that time the python2/3 war was at the highest and you couldn't find reliable documentation. Hell even python3 tutorial kept on blabbering about how python2 concept translated. What was i supposed to do? learn both?

That is why I focused on SQL because at least documentation was quite stable (special thanks to PostgreSQL documentation teams).

I can only imaging the nightmare that must endure rookies frontend dev nowadays.

dmd|2 years ago

Ok, I'll bite - how else do people do this? (Speaking as someone who has ONLY ever done it this way.)

teh_klev|2 years ago

The noscript tag is the correct way to do this. Server side, when you first generate page content you have no idea if the client has scripting enabled, which is why you include a noscript element to advise the user what to do, or redirect them using a meta tag inside the noscript element.

So all these suggestions below to use server side generated HTTP headers and 302 (or 301) redirects are incorrect...because you won't know, on the first page hit, if the client has scripting enabled. At this point in time only the client knows if scripting is available. Also browser capability sniffing based on headers sent from the client in the first request is not reliable.

For more info see:

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/no...

jdlshore|2 years ago

HTTP 3xx status code with a Location header.

scarface74|2 years ago

Most of the time it’s via a server redirect or a rule on the load balancer.

riffic|2 years ago

one way it's not done is with DNS

masenf|2 years ago

I've recently deployed this trick on my company's confluence instance (with an HTML macro) to create a "poor man's" link shortener that allows me to change the link target after the fact.

Also recently deployed it as a very simple server side denounce: when the client first accesses page X a long running operation is dispatched. Subsequent requests for the same resource before it's done processing return a plain HTML response that says "Still thinking about it" and meta refresh after 1 second.

crooked-v|2 years ago

This reminds me of the days of making text adventures that used a width 0 frame to store background variables.

latchkey|2 years ago

I remember when it was released as a new feature (~1995).

TRiG_Ireland|2 years ago

Amazing that these were forgotten!

rawbert|2 years ago

Hehe, the good old html meta redirect. As a kid in the early days of the web I loved to post redirects to porn websites in guestbooks to check if the website was sanitizing the user content properly. Worked way to often :D

mikece|2 years ago

This reminds me that while I’ve been programming for a paycheck since 1998 my knowledge growth in html stopped at about 2001. Are there any good courses or recommendations for seasoned pros who never stopped to learn HTML5?

lioeters|2 years ago

> The term HTML5 is essentially a buzzword that refers to a set of modern web technologies. This includes the HTML Living Standard, along with JavaScript APIs to enhance storage, multimedia, and hardware access.

> You may sometimes hear about "new HTML5 elements", or find HTML5 described as a new version of HTML. HTML5 was the successor to previous HTML versions and introduced new elements and capabilities to the language on top of the previous version, HTML 4.01, as well as improving or removing some existing functionality. However, as a Living Standard HTML now has no version.

Even though it may cover a lot of basic and familiar topics, I think the following is the best (re)introduction to HTML:

HTML: HyperText Markup Language - https://developer.mozilla.org/en-US/docs/Web/HTML

onetrickwolf|2 years ago

Web development has trained me to Google (now often ChatGPT) everything even if I already know how to do it because it changes so much haha

It makes me look stupid in code interviews because I commit very little to memory but professionally it's helped me catch a lot of syntactical upgrades.

javajosh|2 years ago

I use this trick to autorefresh the resource that I'm working on.

moltar|2 years ago

Putting 0 value used to be a bad idea, as it was a signal to the browser and various ad blockers and anti viruses that it was a rogue redirect. Wonder if it’s different these days?

bryanrasmussen|2 years ago

when they just learned about it was in 2020.

fergie|2 years ago

Goddammit!

notRobot|2 years ago

[deleted]

vermilingua|2 years ago

Isn’t this exactly what’s described in the article?

vimax|2 years ago

Wow, I think I can use this for a runtime html log!

arbuge|2 years ago

Not 'official' and yet supported by all major browsers to this day.

Uptrenda|2 years ago

Noob learns basic HTML tag. The post.