3 ms·
Ask HN: How did they do this?
First off, please be kind as I have very little knowledge of coding and such. By very little, I mean essentially none.
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.
- swombat 18y agoI have very little knowledge of coding and such Acquire some knowledge, then ask again if it's not clear.
- gunderson 18y agomeeeow
- alaskamiller 18y agoBack in the good ol' days of the internet, that strip on top of the page was done via HTML frames. Nowadays most people utilize javascript writes in conjunction with frames for graceful degradation usage. Not sure what you're asking about passing the bandwith. I'm not seeing the resizing thing you're mentioning.
- olefoo 18y agoThey use frames. If they are doing what they say they are doing they are using their bandwidth twice. Wikipedia will explain web proxies to you, without telling you that they are mostly skeezy and untrustworthy.
- nostrademons 18y agoView source is your friend. 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> 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.
- zacharye 18y agoThanks for the help! So to hopefully clarify my bandwidth question a bit, and this might be a dumb question, but is there any way for the content of http://free.megaproxy.com/go/<url> http://free.megaproxy.com/go/<url> to completely avoid megaproxy servers? In the specific example of megaproxy I assume they need to run that page through their servers but if someone just wanted to display a webpage in this manner, could they avoid running the third-party site through their servers and just feed the page directly from the source to the viewer?
- nostrademons 18y agoYeah, you could set the frameset src to point directly to the webpage of interest. You lose the ability to alter or read the page content from your address bar, though. (I think; perhaps you could exploit some browser security bugs to do it, but you shouldn't be able to.)
- zacharye 18y ago
- qhoxie 18y ago1. While they do use js for some of their page loading, it is not really js-specific. 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.
- gunderson 18y agoIf they let you be anonymous in a site that requires authentication, then it's a bit more sophisticated. If not then it's probably simple like the other explanations below.
- zacharye 18y agoAwesome guys, thanks so much for the help!