4 Send URL: Opening a Web Browser
See also browser/external, which requires scheme/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 |
Under 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.)
Under Mac OS X, send-url runs osascript to start the user’s chosen browser.
Under Unix, send-url uses the value of the external-browser parameter to select a browser.
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. Also note that the encoding is meant to make the URL work in shell quotes: URLs can still hold characters like #, ?, and &, so the external-browser should use quotations.
| ||||||||||||||||||||||||||||
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 mzscheme exits before that it will not happen – when this function is called it scans old generated files (this happens randomly, not on every call) and removes them to avoid cluttering the temporary directory. If delete-at is #f, no delayed deletion happens, but old temporary files are still deleted as described above.
(external-browser) → browser-preference? |
(external-browser cmd) → void? |
cmd : browser-preference? |
The parameter is initialized to the value of the 'external-browser preference.
The parameter value can be any of the symbols in unix-browser-list, #f to indicate that the preference is unset, or a pair of strings. If the preference is unset, send-url uses the first of the browsers from unix-browser-list for which the executable is found. If the parameter is a pair of strings, then a command line is constructed by concatenating in order the first string, the URL string, and the second string.
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 |