How to remove WebBrowser flicker?
I'm using WebBrowser Control for my chat application. Every time it adds user's message - it refreshes WebBrowser with its new content. And it works good. But after I added a background in html code it started to flicker every time it refreshes. Here's my Navigate() method:
public void Navigate(string url)
{
string text = File.ReadAllText(url);
if (bg.Length > 0)
webBrowser1.DocumentText = text.Replace("%bg%", "background=\"" + bg + "\"");
else
webBrowser1.DocumentText = text;
}
and this is my html file header:
addText("<html>\r\n<head>\r\n<meta charset=utf-8>\r\n</head>\r\n<body %bg% bgproperties=\"fixed\" onload=\"window.scrollTo(0,2147483647);\">\r\n<span style=\"line-height: 20px\" style=\"font-family: Arial; font-size: 14px\">\r\n<font color=black>", NewLine.No);
Every time user adds a message, my program 开发者_高级运维adds it to the end of html file and executes Navigate() method.
Have you got any ideas to remove flicker?
Instead of reloading a new document every time, set the InnerHTML
of the existing Document.Body
.
Add the following 2 lines in your <Head>
tag
<meta http-equiv="Page-Enter" content="blendTrans(Duration=0)">
<meta http-equiv="Page-Exit" content="blendTrans(Duration=0)">
it is working properly.
I added:
<meta http-equiv='Page-Exit' content='filter: expression(document.execCommand("BackgroundImageCache", false, true))'>
to my html code and it's not flashing. I don't know how it works (I don't know html), just spent some time googling for the solution.
And it's strange, because I can replace:
expression(document.execCommand("BackgroundImageCache", false, true))
to anything else and it still works.
精彩评论