
Ask HN: How did they do this? - zacharye
First off, please be kind as I have very little knowledge of coding and such. By very little, I mean essentially none.<p>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<p>I have a couple of questions now.<p>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?<p>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."<p>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?<p>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?<p>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.
======
qhoxie
1\. 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.

------
nostrademons
View 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
Thanks 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
Yeah, 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
Thanks, that's exactly what I needed to know. Much appreciated!

------
alaskamiller
Back 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
They 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.

------
gunderson
If 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
Awesome guys, thanks so much for the help!

------
swombat
_I have very little knowledge of coding and such_

Acquire some knowledge, then ask again if it's not clear.

~~~
gunderson
meeeow

