extension HTController:WKUIDelegate, WKNavigationDelegate,WKScriptMessageHandler {

func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {

if message.name == "setTitle" {

let body = message.body

print(NSLocalizedString("点击了这个方法\(body)",  comment: ""))

}

}

func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {

let colorStyle:String = kUserDefaults.string(forKey: "ColorStyle")!

if colorStyle != "day" {

webView.evaluateJavaScript("document.getElementsByTagName('body')[0].style.background='#333333'", completionHandler: nil)

webView.evaluateJavaScript("document.getElementsByTagName('body')[0].style.webkitTextFillColor= 'white'", completionHandler: nil)

webView.evaluateJavaScript("document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '300%", completionHandler: nil)

}else{

webView.evaluateJavaScript("document.getElementsByTagName('body')[0].style.background='#ffffff'", completionHandler: nil)

webView.evaluateJavaScript("document.getElementsByTagName('body')[0].style.webkitTextFillColor= 'black'", completionHandler: nil)

webView.evaluateJavaScript("document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '300%", completionHandler: nil)

}

}

}

最新文章

  1. UWP开发之Mvvmlight实践四:{x:bind}和{Binding}区别详解
  2. Code::Blocks配置GTK+2和GTK+3
  3. throw er; // Unhandled 'error' event
  4. axure rp pro 7.0(页面原型工具)
  5. PHP框架_Smarty
  6. iOS开发之XMPP即时通讯简单实现
  7. IDE编程环境
  8. JavaScript是如何面向对象的
  9. 2019-04-09 SpringBoot+Druid+MyBatis+Atomikos 的多数据源配置
  10. Mysql连接报错:1130 - Host ‘118.111.111.111’ is not allowed to connect to this MariaDB server
  11. django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call
  12. shell关于变量的操作
  13. MPD软件工作坊北京站:技术创新与研发效率带来的前沿思考
  14. 读书笔记(04) - 错误监控 - JavaScript高级程序设计
  15. SQLSERVER中的元数据锁
  16. JAVA识别字符串是数字(英文)还是汉字,web页面进行字符截断的帮助类
  17. <input type="date">设置默认当前日期
  18. C语言:写一函数,将两个字符串中的元音字母复制到另一个字符串,然后输出
  19. laravel 使用 session
  20. Open XML操作Excel导入数据

热门文章

  1. java.io.IOException: java.io.FileNotFoundException: /tmp/tomcat.2457258178644046891.8080/work/Tomcat/localhost/innovate-admin/C:/up/154884318438733213952/sys-error.log (没有那个文件或目录)
  2. 吴裕雄 Bootstrap 前端框架开发——Bootstrap 显示代码:电脑程序输出: Sample output
  3. Python中self的用法
  4. vue-router重定向redirect
  5. 设计模式课程 设计模式精讲 16-2,3 代理模式Coding-静态代理-1
  6. UniGui安装(01)
  7. VS2010如何在同一个解决方案下建立多个项目以及切换运行不同项目
  8. Kafka源码系列之源码分析zookeeper在kafka的作用
  9. jgrid异步数据加载
  10. RabbitMq学习笔记——概念