1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

WebView利用時によく利用するJavaScriptメモ

Posted at

ユーザーエージェントの取得

let js = "navigator.userAgent"

URLの取得

let js = "document.URL"

タイトルの取得

let js = "document.title"

アンカーを指定してWebView内で画面遷移

let anchor = "#start"
let js = "window.location.hash = \"\(anchor)\""

ズームの禁止

let js = "var meta = document.createElement('meta');" + "meta.name = 'viewport';" + "meta.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no';" + "var head = document.getElementsByTagName('head')[0];" + "head.appendChild(meta);"

ローカルストレージクリア

let js = "localStorage.clear();"

ユーザーのドラッグした、選択範囲の取得

let js = "window.getSelection().toString()"

ロングタップによるActionSheetを表示させない

let js = "document.documentElement.style.webkitTouchCallout='none';"
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?