Live data from Hacker News

I just learned about HTML redirects (2020)

apitman.com

31–40 of 88 posts

Re: I just learned about HTML redirects (2020)

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

{setInterval(function(){document.location.reload();},5000)}

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

Re: I just learned about HTML redirects (2020)

#33

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.

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.

Re: I just learned about HTML redirects (2020)

#34
post #17

Earlier quoted context omitted.

The most common is using an HTTP header. Less common: `document.location` in JavaScript https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirectio...

That wouldn't work in a noscript

Not sure why you're being downvoted. Many of the sibling comments are referring to server side generated HTTP 302 headers, and server side (without lots of fancy shenanigans) you won't know (server side) if the client has disabled scripting on the first page hit.

And document.location is pointless if the client has turned off scripting.

Re: I just learned about HTML redirects (2020)

#35
post #13

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

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

Ok, how does the server or the load balancer know if scripting is enabled on the first request?

Re: I just learned about HTML redirects (2020)

#36
post #30
post #26

Earlier quoted context omitted.

I fondly remember html-only iframe chats.

IIRC CGI:IRC had an even more clever version of this: still no JavaScript needed, but Also no refresh needed, as the chat frame response would simply be held open and stream new messages. I never dug too deep into it, but it seemed to work surprisingly well.

This is called Server Sent Events, SSE for short.

https://developer.mozilla.org/en-US/docs/Web/API/Server-sent...

Re: I just learned about HTML redirects (2020)

#38
post #13

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

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...

Re: I just learned about HTML redirects (2020)

#40
post #36
post #30

Earlier quoted context omitted.

IIRC CGI:IRC had an even more clever version of this: still no JavaScript needed, but Also no refresh needed, as the chat frame response would simply be held open and stream new messages. I never dug too deep into it, but it seemed to work surprisingly well.

This is called Server Sent Events, SSE for short. https://developer.mozilla.org/en-US/docs/Web/API/Server-sent...

That’s the modern variation. The original didn’t have any framing like they.
Post reply on HN