5 Send URL: Opening a Web Browser
See also browser/external, which requires racket/gui, but can prompt the user for a browser if no browser preference is set.
| |||||||||||||||||||||
str : string? | |||||||||||||||||||||
separate-window? : any/c = #t | |||||||||||||||||||||
escape? : any/c = #t |
On Windows, send-url normally uses shell-execute to launch a browser. (If the URL appears to contain a fragment, it may use an intermediate redirecting file due to a bug in IE7.)
On Mac OS X, send-url runs osascript to start the user’s chosen browser.
On Unix, send-url uses a user-preference, or when none is set, it will look for a known browser. See the description of external-browser for details.
The url string is usually escaped to avoid dangerous shell characters (quotations, dollar signs, backslashes, and non-ASCII). Note that it is a good idea to encode URLs before passing them to this function.
On all platforms, external-browser parameter can be set to a
procedure to override the above behavior —
| ||||||||||||||||||||||||||||
path : path-string? | ||||||||||||||||||||||||||||
separate-window? : any/c = #t | ||||||||||||||||||||||||||||
fragment : (or/c string? false/c) = #f | ||||||||||||||||||||||||||||
query : (or/c string? false/c) = #f |
| |||||||||||||||||||||||||||||||||||
contents : string? | |||||||||||||||||||||||||||||||||||
separate-window? : any/c = #t | |||||||||||||||||||||||||||||||||||
fragment : (or/c string? false/c) = #f | |||||||||||||||||||||||||||||||||||
query : (or/c string? false/c) = #f | |||||||||||||||||||||||||||||||||||
seconds : (or/c number? false/c) = #f |
If delete-at is a number, the temporary file is removed after
this many seconds. The deletion happens in a thread, so if racket
exits before that it will not happen —
(external-browser) → browser-preference? |
(external-browser cmd) → void? |
cmd : browser-preference? |
On Unix, the command that is used depends on the 'external-browser preference. If the preference is unset, send-url uses the first of the browsers from unix-browser-list for which the executable is found. Otherwise, the preference should hold a symbol indicating a known browser (from the unix-browser-list), or it a pair of a prefix and a suffix string that are concatenated around the url string to make up a shell command to run. In addition, the external-browser paremeter can be set to one of these values, and send-url will use it instead of the preference value.
Note that the URL is encoded to make it work inside shell double-quotes: URLs can still hold characters like #, ?, and &, so if the external-browser is set to a pair of prefix/suffix strings, they should use double quotes around the url.
If the preferred or default browser can’t be launched, send-url fails. See get-preference and put-preferences for details on setting preferences.
(browser-preference? a) → boolean? |
a : any/c |