Webview.useragent read/write property
Get or set the current Webview User agent string.
A user agent string is a text that web browsers and other client applications send to web servers to identify themselves. It provides information about the software, operating system, and hardware being used, allowing the server to tailor its response accordingly.
Example
local ui = require "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
ui.run(win):wait()