这将在所选目标设备的浏览器上打开指定的 URL,或者,如果您使用的是 HTML5 模块,则在当前打开的浏览器中打开。
当您使用 open() 方法时,您指定的 "target" 参数与标准的 JavaScript "name" 值相同 (请注意,除 "_self" 之外的所有参数都可能导致浏览器被阻止,或询问用户是否希望允许它),而 "options" 参数与用于控制新窗口 / 选项卡应显示哪些属性的 JavaScript "specs" 参数相同 (并非所有浏览器都支持所有功能)。
有效的目标是:
| 目标 | 描述 |
|---|---|
| _blank | Opens the linked document in a new window or tab (this will not work if pop-ups are being blocked by the user, in which case you can use the clickable_* functions instead). |
| _self | Opens the linked document in the same frame as it was clicked (this is default). |
| _parent | Opens the linked document in the parent frame. |
| _top | Opens the linked document in the full body of the window. |
有效的选择包括:
| 参数 | 描述 |
|---|---|
| 'height=[px]' | The height of the window, with the minimum value being 100. |
| 'width=[px]' | The width of the window, with the minimum value being 100. |
| 'left=[px]' | The left position of the window. |
| 'top=[px]' | The top position of the window (IE only). |
| 'location=[boolean]' | Whether or not to display the address field (default is 1). |
| 'menubar=[boolean]' | Whether or not to display the menu bar (default is 1). |
| 'resizable=[boolean]' | Whether or not the window is resizable (default is 1). |
| 'scrollbars=[boolean]' | Whether or not to display scroll bars (default is 1). |
| 'status=[boolean]' | Whether or not to add a status bar (default is 1). |
| 'titlebar=[boolean]' | Whether or not to display the title bar. This is ignored unless the calling application is an HTML Application or a trusted dialog box (default is 1); |
| 'toolbar=[boolean]' | Whether or not to display the browser toolbar (default is yes). |
注意 安装在玩家设备上的杀毒软件可能导致URL无法打开,因此在使用此函数时请注意这一点。
url_open_full(url, target, options);
| 参数 | 类型 | 描述 |
|---|---|---|
| url | String | 要链接到的url(网址)。 |
| target | String | 这是打开 URL 的目标区域 (请参阅说明)。这只在 HTML5 中使用。 |
| options | String | 标准浏览器选项 (请参阅说明)。这只在 HTML5 中使用。 |
N/A
url_open_full("http://gamemaker.io", "_blank", "resizable=0, height=200, scrollbars=0");
这将在一个无法调整大小的新窗口中打开 GameMaker 主页,该窗口的高度为 200 像素,在 HTML5 中运行或在所选目标设备的浏览器的新窗口中运行时没有滚动条。