函数:openURL 打开网络地址

函数名称:打开网址

函数功能:调用系统浏览器,打开一个指定网址

函数方法

openURL(url)

返回值:无

参数 类型 必填 说明
url string 需要打开的目标网址

脚本实例

调用系统浏览器打开触动精灵官网

openURL("http://www.touchsprite.com");

访问 iOS 系统功能页面

openURL("prefs:root=WIFI");              --打开 WiFi 界面
openURL("prefs:root=LOCATION_SERVICES"); --打开定位服务界面
openURL("prefs:root=General&path=VPN");  --打开 VPN 界面
--如果网址有特殊符号使用此函数网页内容显示不对,可以在网址中加下单引号后再试下
openURL("'https://www.baidu.com/s?ie=utf-8&wd=%E8%A7%A6%E5%8A%A8%E7%B2%BE%E7%81%B5'")
--如果安卓使用此函数但是 url 参数内容为非 https 或者 http 开头的,请修改成以下方式再试
url = "pinduoduo://com.xunmeng.pinduoduo/goods.html?goods_id=110828199907"
os.execute(string.format("am start -a android.intent.action.VIEW -d "..url))

注意事项

  • 默认情况下调用的浏览器为系统默认浏览器。
  • 欲打开的目标网址必须以 http:// 开头,一些特殊协议也是支持的,Android 系统如:sms:, tel:,iOS 系统如:mailto://, sms://, tel://, ifile://, cydia:// 等等。
  • iOS 常用应用 URLScheme 请看 https://www.touchsprite.com/docs/8603
  • iOS 支持跳转的设置页面详见 iOS 系统设置参数对照表
Copyright 北京帮你玩科技有限公司 2023 all right reserved,powered by Gitbook该文章修订时间: 2024-03-06 17:50:18

results matching ""

    No results matching ""