Ask HN: How did they do this?
In years past, I have come across a bunch of sites such as https://www.megaproxy.com/freesurf/. The specific functionality of this site is irrelevant - what I am curious about is one specific aspect. When the user enters an address (s)he wants to surf anonymously, the result is the external page desired but with a "megaproxy bar" across the top that stays fixed as you scroll on the page. Here is an example (Hacker News): http://bit.ly/B9t1s
I have a couple of questions now.
1. How did they do this? Is it just a custom javascript? Is it very complex? Is there more than one way to do it?
2. How would you describe this to another coder? I can only imagine the odd stare I would get if I said, "You know, one site displays a page from another site but keeps a header at the top and it remains stationary as you scroll and stays at the top even as they click links on the page."
3. Who passes the bandwidth? I see that resulting pages have a megaproxy URL in the linked example but does the actual page content pass over their servers? Maybe it does in this case due to the nature of the site, but does it have to?
4. When the user enters the desired URL on megaproxy and goes to the site, the browser seems to be resized automatically. Is there a way to avoid this?
I've spent some time searching Google but without knowing the proper terminology to search I'm having a hard time. Thanks in advance for your help.
2. The bar at the top remains in a 'fixed' position over the rest of the page. Hence the 'position: fixed' CSS property that can achieve this effect. The way they do it is with frames, though.
3. Both sites do. It appears that the proxy pulls the markup from the page specified, appends it to their page, and then sends it to you.
4. This is done via js. You could use something like firebug to modify this behavior if you really wanted to.
It's creating a frameset. The top frame is the address bar. The bottom frame is the content. When you enter an address in the top frame, it sets the source of the bottom frame to http://free.megaproxy.com/go/<url>. This goes out to the Internet, retrieves <url>, and rewrites all links to point to the appropriate megaproxy pages, so that you continue surfing through megaproxy.
When I was at my first job - way back when it was still a "teen content dot-com run exclusively by teenagers" - I wrote a little script that did exactly this, except that I rewrote the links so that they would float around the page and bounce off the edges of the window. I called it the LinksJynx. Then my boss yelled at me for wasting company time on frivolous coding projects like that. Personally I thought that was a little harsh, since I spent like 3 hours on it and that was far less than the amount of time I spent reading Harry Potter fanfiction on the job (or, for that matter, less than the amount of time the other engineers spent looking at porn and fucking the CTO's niece). But whatever.
Not sure what you're asking about passing the bandwith.
I'm not seeing the resizing thing you're mentioning.
Wikipedia will explain web proxies to you, without telling you that they are mostly skeezy and untrustworthy.
Acquire some knowledge, then ask again if it's not clear.