Open huseyinseyit opened 1 year ago
If the sample app is modified as below, you can click https://www.google.com and the page will be loaded.
diff --git a/sample/Assets/Scripts/SampleWebView.cs b/sample/Assets/Scripts/SampleWebView.cs
index 21a6e87..f0a91a7 100644
--- a/sample/Assets/Scripts/SampleWebView.cs
+++ b/sample/Assets/Scripts/SampleWebView.cs
@@ -157,6 +157,19 @@ public class SampleWebView : MonoBehaviour
webViewObject.SetTextZoom(100); // android only. cf. https://stackoverflow.com/questions/21647641/android-webview-set-font-size-system-default/47017410#47017410
webViewObject.SetVisibility(true);
+ webViewObject.LoadHTML(@"
+<html>
+ <head>
+ <meta http-equiv=""Content-Type"" content=""text/html; charset=UTF-8"">
+ <title>Unity WebView</title>
+ </head>
+ <body>
+ <a href=""https://google.com"">https://google.com</a>
+ </body>
+</html>
+",
+ "/");
+ yield break;
#if !UNITY_WEBPLAYER && !UNITY_WEBGL
if (Url.StartsWith("http")) {
webViewObject.LoadURL(Url.Replace(" ", "%20"));
LoadHTML corresponds to the followings. Links may/may not be loaded depending on the specified baseUrl.
Thanks for the quick response. I get it from the server as the html string I uploaded. Also, when I read the html example you gave as a string, the link does not open again. For example; string a="
<html>
<head>
<meta http-equiv=""Content-Type"" content=""text/html; charset=UTF-8"">
<title>Unity WebView</title>
</head>
<body>
<a href=""https://google.com"">https://google.com</a>
</body>
</html>
";
webViewObject.LoadHTML(a);
Your example doesn't have any <a>
tag.
(Edit) Or, you might paste without markdown. Please check https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks . Also, you should try the precisely same modification that I described.
I edit, there is tag.
I've put https://github.com/gree/unity-webview/tree/example-for-899/sample that can be directly opened and built with 2020.3.45f1 . Please try this sample.
I think I didn't explain the situation well my friend. I am pulling my html content from server as string when application at runtime. Then I use the webViewObject.LoadHTML function. In this way, the links do not work.
string a=someting; // something=some html code in string get from server. webViewObject.LoadHTML(a); links don't open.
Once html code is represented as a string, it is just a string, right? LoadHTML() cannot detect your server from the string.
Have you tried https://github.com/gree/unity-webview/tree/example-for-899/sample ?
Hi, When I click on the links in the html I loaded with webViewObject.LoadHTML, the links do not open.