轉到內容

SuperCard 程式設計/技巧秘籍/向預設瀏覽器傳送 URL

來自 Wikibooks,開放世界的開放書籍

SuperCard 的 send 命令是向瀏覽器傳送 URL 的規定方式

on mouseUp
  send [URL] to program [name of browser] with "GURLGURL" without reply
end mouseUp

示例

on mouseUp
  send "http://supercard.us" to program "Safari" with "GURLGURL" without reply
end mouseUp

該方法存在的問題是,你的程式不應假設使用者希望使用 Safari 或其他任何特定瀏覽器開啟 URL。

幸運的是,你可以使用 SuperCard 的 shell 函式在使用者的預設瀏覽器中載入 URL

get shell ("open http://supercard.us")

如果你不想硬編碼 URL,可以從欄位中獲取它

on mouseUp
  put [cd/card/bg/background] field [name of field] into [name of variable]
  get shell("open " & [name of variable])
end mouseUp

示例

on mouseUp
  put bg field FieldURL into theURL
  get shell("open " & theURL)
end mouseUp
華夏公益教科書