Swift Open Link in Safari

It’s not “baked in to Swift”, but you can use standard UIKit methods to do it. Take a look at UIApplication’s openUrl(_:) (deprecated) and open(_:options:completionHandler:). Swift 4 + Swift 5 (iOS 10 and above) guard let url = URL(string: “https://stackoverflow.com”) else { return } UIApplication.shared.open(url) Swift 3 (iOS 9 and below) guard let url = … Read more

JavaFX 8 WebEngine: How to get console.log() from javascript to System.out in java?

The following code redirects console.log() to JavaBridge.log(): import netscape.javascript.JSObject; […] public class JavaBridge { public void log(String text) { System.out.println(text); } } // Maintain a strong reference to prevent garbage collection: // https://bugs.openjdk.java.net/browse/JDK-8154127 private final JavaBridge bridge = new JavaBridge(); […] webEngine.getLoadWorker().stateProperty().addListener((observable, oldValue, newValue) -> { JSObject window = (JSObject) webEngine.executeScript(“window”); window.setMember(“java”, bridge); webEngine.executeScript(“console.log = … Read more

How to render a local HTML file with flutter dart webview

I am using the webview_flutter plugin from the Flutter Team. Steps Add the dependency to pubspec.yaml: dependencies: webview_flutter: ^0.3.20+2 Put an html file in the assets folder (see this). I’ll call it help.html. Get the html string in code and add it to the webview. import ‘dart:convert’; import ‘package:flutter/material.dart’; import ‘package:flutter/services.dart’; import ‘package:webview_flutter/webview_flutter.dart’; class HelpScreen … Read more