Webview.useragent
Get or set the current Webview User agent string.
Example
--! luart-extensions
import ui
require "webview"
local win = ui.Window("Webview.useragent property example", "fixed", 320, 200)
local wv = ui.Webview(win, 0, 0, 320, 160)
local btn = ui.Button(win, "Click to change Webview.useragent")
btn:center()
btn.y = 166
function btn:onClick()
wv.useragent = "Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/42.0"
wv:reload()
end
function wv:onReady()
wv.statusbar = false
wv.devtools = false
wv.contextmenu = false
wv.acceleratorkeys = false
-- load an HTML page that will display the current userAgent
wv:loadstring([[
<h1>Your User Agent</h1>
<p id="userAgent"></p>
<script>
document.geElementById("userAgent").textContent = navigator.userAgent;
</script>
]])
end
await win:showasync()