36
\$\begingroup\$

Your job is to open a browser window of the default browser to http://codegolf.stackexchange.com.

Your code must open the browser itself, and cannot rely on an open one.

This is , so the shortest answer in bytes wins.


Moderator note: A large number of answers to this challenge use the URLs http://ppcg.lol or http://ppcg.ga. These URLs did direct to https://codegolf.stackexchange.com at the time, but have since expired. By this meta discussion, they have been allowed to stay, with the note that they are currently invalid.

\$\endgroup\$
25
  • 10
    \$\begingroup\$ Are URL shorteners allowed? \$\endgroup\$
    – isaacg
    Mar 30, 2016 at 15:01
  • 5
    \$\begingroup\$ Is it allowed to run JavaScript in the default browser to open a window? \$\endgroup\$
    – Mwr247
    Mar 30, 2016 at 15:30
  • 5
    \$\begingroup\$ @Mwr247 No, it is not. \$\endgroup\$ Mar 30, 2016 at 15:49
  • 16
    \$\begingroup\$ You should add clarifications/restrictions to the question itself, since comments are not guaranteed to stick around forever. \$\endgroup\$
    – user45941
    Mar 30, 2016 at 16:01
  • 9
    \$\begingroup\$ Your spec is minimal, which led to alot of uncertainty over what is allowed to accomplish the task. Additionally, some probably consider it a trivial task. Still, you're in the positive ;) \$\endgroup\$
    – Mwr247
    Mar 30, 2016 at 17:16

50 Answers 50

1
2
1
\$\begingroup\$

C++, 61 Bytes

#include <cstdlib>
main(){system("xdg-open http:ppcg.lol");}

Just a rip off of the bash solution using system, and it only works on systems using the freedesktop tools. Also shortened by using the short link some kindly provided, otherwise it would be much longer.

\$\endgroup\$
1
1
\$\begingroup\$

Windows Batch, 17 bytes

start www.gfa1.tk
\$\endgroup\$
3
  • \$\begingroup\$ You should include the language for this. Also, this is a trivial improvement upon an existing answer, and thus it should have been a comment rather than a separate answer. \$\endgroup\$
    – user45941
    Apr 2, 2016 at 2:14
  • \$\begingroup\$ ppgc.ga is working now. \$\endgroup\$
    – Tim
    Apr 2, 2016 at 20:35
  • 1
    \$\begingroup\$ Please note that the URL gfa1.tk longer works, and it is recommended you update your answer to a URL that does work, ideally codegolf.stackexchange.com. For more information, see the note in the challenge, or this meta discussion \$\endgroup\$ Jan 7, 2023 at 23:54
1
\$\begingroup\$

Perl 6, 45 bytes

Requires the Browser::Open module.

use Browser::Open;open_browser 'http:ppcg.ga'
\$\endgroup\$
3
  • \$\begingroup\$ Do you really need that one whitespace? I can't test this right now. \$\endgroup\$
    – cat
    Apr 29, 2016 at 12:26
  • \$\begingroup\$ Yes, Perl 6 has strict whitespace requirements. \$\endgroup\$
    – Ming-Tang
    Apr 30, 2016 at 3:34
  • \$\begingroup\$ Please note that the URL ppcg.ga no longer works, and it is recommended you update your answer to a URL that does work, ideally codegolf.stackexchange.com. For more information, see the note in the challenge, or this meta discussion \$\endgroup\$ Jan 7, 2023 at 23:56
1
\$\begingroup\$

Python, 44 bytes

from webbrowser import*;open('http:ppcg.ga')

URL from this comment
Edit: ppcg.ga seems to become more popular now (but it WAS available when I posted this answer).

Ungolfed:

from webbrowser import * # Loads everything in the webbrowser module
open("http://ppcg.ga/") # Opens default browser to http://ppcg.ga/

Python, 44 bytes

from webbrowser import*;open('http:gfa1.tk')

URL from this answer

Ungolfed:

from webbrowser import * # Loads everything in the webbrowser module
open("http://gfa1.tk/") # Opens default browser to http://gfa1.tk/

Python, 45 bytes

from webbrowser import*;open('http:ppcg.lol')

Ungolfed:

from webbrowser import * # Loads everything in the webbrowser module
open('http://ppcg.lol/') # Opens default browser to http://ppcg.lol/

Take that, ppcg.lol! (1 byte shorter)

Note: I added a separate answer leading to ppcg.lol, 'cause I've noticed the other sites doesn't work for me in Internet explorer 11, and I saw other users having this problem too.

Both are non-non-competing (read that right?)

\$\endgroup\$
1
1
\$\begingroup\$

Lua, 30 Bytes

os.execute'start http:ppcg.ga'
\$\endgroup\$
1
1
\$\begingroup\$

Ruby, 22 20 19 bytes (on OS X)

`open http:ppcg.ga`

Simple.

Thanks to Daniel for 2 bytes off.

\$\endgroup\$
5
  • \$\begingroup\$ You can save 2 characters by using backticks instead of %x. open http:ppcg.lol \$\endgroup\$ Mar 31, 2016 at 7:31
  • \$\begingroup\$ @DanielEvans Great, thanks. That saves 2 bytes. \$\endgroup\$
    – Riker
    Mar 31, 2016 at 15:18
  • 1
    \$\begingroup\$ "'open' is not recognized as an internal or external command, operable program or batch file." \$\endgroup\$ Apr 1, 2016 at 18:07
  • 1
    \$\begingroup\$ @DewiMorgan OS X only. \$\endgroup\$
    – Riker
    Apr 1, 2016 at 22:35
  • \$\begingroup\$ Please note that the URL ppcg.ga no longer works, and it is recommended you update your answer to a URL that does work, ideally codegolf.stackexchange.com. For more information, see the note in the challenge, or this meta discussion \$\endgroup\$ Jan 7, 2023 at 23:55
1
\$\begingroup\$

Cheddar, 65 bytes

cheddar.internal(cheddar.uid).require("open").c("http://ppcg.ga")

Accesses cheddar internals and then calls upon open package and calls it with string to PPCG. Make sure you have open npm package installed

\$\endgroup\$
2
  • \$\begingroup\$ Shouldn't this be Cheddar+Open if it requires another package? \$\endgroup\$
    – Pavel
    Feb 25, 2017 at 3:54
  • \$\begingroup\$ Please note that the URL ppcg.ga no longer works, and it is recommended you update your answer to a URL that does work, ideally codegolf.stackexchange.com. For more information, see the note in the challenge, or this meta discussion \$\endgroup\$ Jan 7, 2023 at 23:55
1
\$\begingroup\$

05AB1E, 16 bytes

The features used here postdate the challenge, but that's fine. Code:

’…Ò ™³.ÐÏg.´¢’.E

You can try the string online here. This basically evaluates to this batch answer.

Uses the CP1252 encoding.

\$\endgroup\$
3
  • \$\begingroup\$ How do you count the bytes? Depending which program I use for counting I get from 21 to 34 bytes. \$\endgroup\$
    – sqlab
    Mar 31, 2016 at 8:57
  • \$\begingroup\$ @sqlab 05AB1E uses the CP1252 encoding. \$\endgroup\$
    – Adnan
    Mar 31, 2016 at 9:01
  • 1
    \$\begingroup\$ Please note that the URL ppcg.lol no longer works, and it is recommended you update your answer to a URL that does work, ideally codegolf.stackexchange.com. For more information, see the note in the challenge, or this meta discussion \$\endgroup\$ Jan 7, 2023 at 23:56
1
\$\begingroup\$

Vyxal 7 bytes

`∨¤ β`E

Try it Online!

The short dictionary is a neat hidden feature, compressing the codegolf link to β

\$\endgroup\$
0
\$\begingroup\$

NodeJS, 53 bytes

require('child_process').exec('open http://ppcg.lol')

Works on mac.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ Duplicate of this \$\endgroup\$
    – user45941
    Mar 30, 2016 at 18:58
  • \$\begingroup\$ Please note that the URL ppcg.lol no longer works, and it is recommended you update your answer to a URL that does work, ideally codegolf.stackexchange.com. For more information, see the note in the challenge, or this meta discussion \$\endgroup\$ Jan 7, 2023 at 23:56
0
\$\begingroup\$

Python, 43 41 40 bytes

import os
os.system("open http:ppcg.ga")
  • -2 bytes thanks to @Quill.
  • -1 byte thanks to @MDXF.
\$\endgroup\$
8
  • \$\begingroup\$ Duplicate of this \$\endgroup\$
    – user45941
    Mar 30, 2016 at 18:57
  • 4
    \$\begingroup\$ @mego how is it a duplicate - It's not even the same language! \$\endgroup\$ Mar 30, 2016 at 22:30
  • \$\begingroup\$ @proudhaskeller See my comments on this answer \$\endgroup\$
    – user45941
    Mar 30, 2016 at 23:56
  • \$\begingroup\$ @mego on the nominations for moderator you said yo believe in hands-off moderation. I don't see how this is reflected here. \$\endgroup\$ Mar 31, 2016 at 6:03
  • \$\begingroup\$ @proudhaskeller By hands-off moderation, I mean letting the community do all the moderation work that it can, rather than stepping in with mod powers. As I am neither a moderator nor using moderation powers/privileges, this is still hands-off moderation. If you wish to discuss my views on moderation further, I would encourage you to do so with me in the chatroom created specifically for that purpose. \$\endgroup\$
    – user45941
    Mar 31, 2016 at 6:10
0
\$\begingroup\$

Nim, 47 bytes

import browsers
openDefaultBrowser"www.ppcg.ga"
\$\endgroup\$
1
0
\$\begingroup\$

C# (Full Class) 89 bytes

class P{static void Main(string[]a){System.Diagnostics.Process.Start("http://ppcg.ga");}}

Not sure that it's possible to write a full class (with the System.Diagnostics reference) any shorter.

Inside main method only without references, 32 bytes:

Process.Start("http://ppcg.ga");
\$\endgroup\$
1
0
\$\begingroup\$

Dyalog APL, 20 19 bytes

-1 byte thanks to MD XF

]Open http://ppcg.ga

Uses the User Command ]Open, which is installed with Dyalog.

\$\endgroup\$
3
  • \$\begingroup\$ Needs you the //? \$\endgroup\$ Mar 30, 2016 at 19:31
  • 1
    \$\begingroup\$ @CoolestVeto Yes, otherwise you get an error: * Command Execution Failed: File not found \$\endgroup\$
    – Adám
    Mar 30, 2016 at 19:34
  • \$\begingroup\$ Please note that the URL ppcg.ga no longer works, and it is recommended you update your answer to a URL that does work, ideally codegolf.stackexchange.com. For more information, see the note in the challenge, or this meta discussion \$\endgroup\$ Jan 7, 2023 at 23:57
0
\$\begingroup\$

Python, 40 bytes

__import__('webbrowser').open('ppcg.ga')

Shorter version of everything else.

\$\endgroup\$
1
0
\$\begingroup\$

VBScript, 47 bytes

CreateObject("WScript.Shell").Run"http:ppcg.gq"
\$\endgroup\$
0
0
\$\begingroup\$

URL, 58 bytes

[InternetShortcut]
URL=https://codegolf.stackexchange.com

In Windows create a file "url.URL", with a code editor put the code.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Welcome to the site! As it isn't clear whether this works or not, could you provide either instructions for running this, or a link to an online testing environment such as TryItOnline!, so that others can verify your answer? \$\endgroup\$ Sep 21, 2019 at 19:01
-1
\$\begingroup\$

R, 28 bytes

browseURL("http://ppcg.lol")

(in utils package)

\$\endgroup\$
1
-1
\$\begingroup\$

C (gcc), 49 38 37 bytes

main(){system("start http:ppcg.ga");}

It's for Windows.

\$\endgroup\$
1
-1
\$\begingroup\$

SX, 38 bytes

的 webbrowser im**;o&('http:ppcg.ga')

Save this shell script as SXexec.sh to your SX directory:

#!/bin/sh
N=$1.py;python Main.py $1;wine SXCompiler.exe $N;rm $N;python $N.py;rm $N.py

The script features tidying up after execution. To execute the above script, you need to have Wine and Python. Usage is like this:

SXexec.sh file
\$\endgroup\$
1
1
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.