I decided that I wanted to take a quick stop in Slovakia while traveling from Vienna to Budapest. From my online research, it seemed as if something like this was possible. However, I was a bit nervous going into my trip that I would get stuck in Bratislava, Slovakia because the online information I found was vague and confusing. Luckily, everything went off without a hitch and other than getting rained on and getting a bit lost in Bratislava, it was a perfect little stop between Vienna and Budapest.
If you too want to visit Bratislava, there is no need to buy tickets in advance. Simply show up to the Vienna Hauptbahnhof Central Station. There, go to the international train office and ask for a ONE WAY ticket to Bratislava (this costs roughly 10 euro). This ticket is valid for any time and they will also give you a map of Bratislava. The train departs every hour from 5:20 to 22:21 so you have plenty of options. If you have time to wait before your train leaves, you can relax at the station and grab something to eat (it is newly renovated and has wifi!).
Once you get on the train, there are likely going to be a number of stops before you arrive in Bratislava. When you get to Bratislava, you can take the public bus or tram into the center of town. There you will find plenty of shops, restaurants and historical buildings. Be warned that the map provided from the train station is a bit confusing.
When you feel as if you are ready to continue on to Budapest, simply head back to the station on the same bus (going the opposite direction) and buy your one way ticket to Budapest. This cost me roughly 17 euro. The train comes every two hours from 5:50 to 19:54. The train to Budapest takes about 2 hours and 40 minutes with stops in between.