Your specific questions
I understand that I obviously can get a virus by downloading and executing a .exe in Windows but how can I get a virus just by accessing a website ?
Your browser is executing code all the time (it is made of code). When it downloads web pages, that code is downloading and displaying arbitrary data (pixels, characers, etc).
Code is also data (at the processor level).
Since code is data, if your browser tries to execute the data (no matter what the file extension or format), it might actually run (if crafted correctly).
Normally your browser won't be so foolish as to try to run random data it downloaded. However, this can happen.
One way to do this is to form the data in such a way that when read, it will "leak through" and overwrite the data that makes up the browser's executable program. This requires the browser to have a bug (most commonly in this case, allowing a buffer overrun).
Your browser also runs programs on top of web pages. Javascript, as you mentioned, is one such type of code. But there are dozens. ActiveX, Flash, add-ons, grease monkey scripts, etc. are all code which you are running while visiting web pages. This code can contain bugs that cause security breeches.
Do these viruses attack both Windows, Mac and Linux users or are Mac/Linux users immune ?
No platform we use is completely immune to bugs, because they are all using processors that treat data as code. This is simply how our existing computer architecture works.
The reason for this myth is that Mac and Linux have much lower adoption rates compared to Windows machines (at the desktop level). So desktop software on these machines is not as common a target for virus makers.
Viruses don't occur by magic, or by happen-stance evolution (as biological viruses do). It is software written by individuals, or teams of developers. And they want to target the biggest market share, the same way regular software vendors do.
As for whether one virus can target multiple platforms; All browsers are running different code, so will have different bugs (even the same browser on different platforms). But there are some code libraries that are shared across platforms. If such a library contains the bug, it is possible that the exploit could exist on multiple platforms.
But, depending on the type of attack made, a virus written for a non-Intel Mac might not work on an Intel Mac, and vice-versa, because they have different processors. For different processors, the data that represents the code has a different format.
When you're talking about a virtual machine or scripting language, though, attacks might be platform independent. That leads us to the next question...
Are the viruses programmed in JavaScript?
Some viruses are. The information I stated above (about buffer overrun exploits) would usually be used as an attack outside Javascript, but could equally well apply to a virus crafted to attack an exploit in a Javascript interpreter.
Javascript will also have its own set of exploits, at an operating level that is above buffer overruns. There are a whole host of ways to attack any piece of software. The bigger the software is (lines of code), the more varieties of user input (in this case, types of code) it is likely to receive, and the more bugs it can contain.
Also, the more exposed a running piece of software (e.g. software running a server), the more vulnerable it is to attack.
In general, this is called Attack Surface
Exploits in general
Microsoft has a mnemonic for common exploit types, and they all have their own interesting properties, and different levels of software that they can attack - STRIDE, which stands for:
Spoofing (of user identity)
Tampering
Repudiation
Information disclosure (privacy breach or Data leak)
Denial of Service (D.o.S.)
Elevation of privilege
Some of these are more likely to be used in an attack based on Javascript than others, some on servers, some on data files (such as images).
But security is a big and evolving field. There is really too much information to completely answer all of your questions.