Android Question webview and html

Almora

Well-Known Member
Licensed User
Longtime User
<HTML><HEAD>
<TITLE>test</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1254">
<style type="text/css">.style12 { color: #FFFFFF; font-weight: bold;}</style>
</HEAD>
<BODY leftMargin=0 topMargin=0 bgcolor="#eeeeee">
<center>
<table width="671" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#000099">
<tr><td width="671"><div align="center" class="style12">test</div></td></tr>
</table>
<script src="//play.player.im/player/playlist.php?uid=525"></script>
</center> </BODY></HTML>

hi..
I can't show this code on webview.
How can I show with webview?
the code i use

B4X:
   .....
  WebView1.Initialize("")
  WebViewExtras1.Initialize(WebView1)
  Dim WebChromeClient1 As DefaultWebChromeClient
  WebChromeClient1.Initialize("WebChromeClient1") 
   WebViewExtras1.SetWebChromeClient(WebChromeClient1)

'WebViewExtras1.LoadHtml("")
WebView1.LoadHtml($"<!DOCTYPE html>
<html>
<head>
<title>test</title>
<script type='text/javascript' src='//play.player.im/player/playlist.php?uid=525'></script>
</head>
<body>
</body>
</html>"$)
 
Last edited:

drgottjr

Expert
Licensed User
Longtime User
first, your src='' is illegal. protocol missing. webview doesn't know what you want (http, https, etc)
and even after you add the protocol, you trigger a cors violation.
i gather you want to play music or some medi, but you can't do it like you're doing.
you should try to run your html in chrome on your desktop and then look at the developer's tab. you'll see exactly what the error is.
webview is not chrome. some things that work in chrome do not work in webview.
 
Upvote 0

Almora

Well-Known Member
Licensed User
Longtime User
src='' is illegal. protocol missing. webview doesn't know what you want (http, https, etc)
I have tried them. but I could not open it.
I can open the code in the online compiler. here
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Have you tried set JavaScriptEnabled to True ?
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Have you checked this post?
 
Upvote 0

Almora

Well-Known Member
Licensed User
Longtime User
test.html
as I added to assets. but yime did not succeed.
I am trying it in Quickedit+.apk text editor, it opens very well.
 

Attachments

  • Screenshot_20210303-123011_QuickEdit+.jpg
    223.1 KB · Views: 302
  • PicsArt_03-03-12.32.04.jpg
    146.8 KB · Views: 275
Last edited:
Upvote 0

aeric

Expert
Licensed User
Longtime User
I afraid the content is blocked due to cross origin.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Can you open the html file from windows desktop?
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
no
but it works in online preview
What do you mean by online preview?

I can’t open the page maybe due to different country or cross origin reason.

Do you manage to show if using iframe tag?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…