开发者

Does webview take HTML tag <object>?

开发者 https://www.devze.com 2023-04-03 21:06 出处:网络
I tried many times and try to use HTML tag <object>, but app just crash and disappear. Each time when I use normal html tag such as <html>, <body>, <h1>, <div>, <td&g

I tried many times and try to use HTML tag <object>, but app just crash and disappear.

Each time when I use normal html tag such as <html>, <body>, <h1>, <div>, <td>, <tr> etc. Those can be shown directly without any error.

This time I try to embed an <object> tag to webview and it always crash! Does anyone who know how to do this directly inside code? OR, webview just cannot do this?

here is my code.


String html = 
  "<html>" +
  "<body><h1>This is a test !!</h1>" +
  "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='200' height='200'></object>" +
  "<param name='quality' value='high'>" +
  "<param name='allownetworking' value='internal'>" +
  "<param name='allowScriptAccess' value='never'>" +
  "<param name='movie' value='http://video.yutube.com/flv2.swf?i=20100129LqvamMPB&amp;d=360.25&amp;movie_stop=off&amp;no_progressive=1&amp;otag=1&开发者_运维百科amp;sj=5&amp;rel=1'>" +
  "<param name='allowFullScreen' value='true'>" +
  "<embed src='http://video.yutube.com/flv2.swf?i=20100129LqvamMPB&amp;d=360.25&amp;movie_stop=off&amp;no_progressive=1&amp;otag=1&amp;sj=5&amp;rel=1' width='200' height='200' quality='high' allownetworking='internal' allowscriptaccess='never' allowfullscreen='true' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed>" +
  "</object>" +
  "</body></html>";

mWebView.loadDataWithBaseURL("", html, "text/html", "utf-8", "");


You have one <object> tag and two </object> tags. The first </object> has got to go.

The embed tag is for browsers that don't recognize the object tag. Those browsers will see the embed tag and will try to use it. Browsers that support the object tag will use the object and ignore the embed, as long as the embed is within the object. If the embed is outside the object, object aware browsers may load both the object and embed tags.


WebView can definitely handle the html tag. I don't think you should use loadDataWithBaseURL though, try this instead:

mWebView.loadData(html, "text/html", "UTF-8");

I'm not too sure your <object> will work though...

Here's a better way to play a YouTube video if that's all you need:

startActivity(new Intent(Intent.ACTION_VIEW, 
   Uri.parse("http://www.youtube.com/watch?v=<video-id>")));

Put your video id in place of the <video-id>

0

精彩评论

暂无评论...
验证码 换一张
取 消