Windowsless property not working in Firefox ONLY
I made a simple silverlight program to display some realtime text from xml. Text display using HTML DIV tag. I added a plugin property windowless = true, enablehtmlaccess = true, background = transparent.
In Silverlight, I've added a " Continue " button at the top and bottom that displays some kind of message on this click.
Resize Silverlight plugin based on XML content.
My code:
MainPage.xaml:
<Grid x:Name="LayoutRoot">
<StackPanel HorizontalAlignment="Right" VerticalAlignment="Top">
<Button x:Name="topContinue" Content="Continue" Margin="0,30,30,0" Click="Continue_Click"></Button>
</StackPanel>
<StackPanel HorizontalAlignment="Right" VerticalAlignment="Bottom">
<Button x:Name="bottomContinue" Content="Continue" Margin="0,0,30,30" Click="Continue_Click"></Button>
</StackPanel>
</Grid>
MainPage.xaml.cs:
Create HTML DIV in Application Start Using:
HtmlDocument _document = HtmlPage.Document;
HtmlElement iDIV = _document.CreateElement("DIV");
iDIV.SetAttribute("id", "divHTMLViewer");
iDIV.SetStyleAttribute("position", "absolute");
iDIV.SetStyleAttribute("z-index", "1");
iDIV.SetStyleAttribute("display", "INLINE");
iDIV.SetStyleAttribute("top", "100px");
iDIV.SetStyleAttribute("height", "0px");
iDIV.SetStyleAttribute("width", "96%");
iDIV.SetStyleAttribute("left", "15px");
iDIV.SetStyleAttribute("text-align", "justify");
HtmlElement body = _document.GetElementsByTagName("BODY")[0] as HtmlElement;
body.RemoveChild(iDIV);
body.AppendChild(iDIV);
Install XML text:
HtmlElement divHTMLViewer = HtmlPage.Document.GetElementById("divHTMLViewer");
sText = sText.Replace("<", "<").Replace(">", ">");
divHTMLViewer.SetStyleAttribute("display", "none");
divHTMLViewer.SetStyleAttribute("width", "96%");
divHTMLViewer.SetStyleAttribute("top", "100px");
divHTMLViewer.SetStyleAttribute("left", "15px");
divHTMLViewer.RemoveStyleAttribute("color");
divHTMLViewer.RemoveStyleAttribute("fontSize");
divHTMLViewer.SetProperty("innerHTML", sText);
divHTMLViewer.SetStyleAttribute("display", "INLINE");
setSilverlightControlHeight(UILAYOUT.INSTRUCTIONS);
Silverlight plugin resizing code:
isilverlightControlHost.SetStyleAttribute("height", HtmlPage.Window.Eval("document.documentElement.scrollHeight").ToString() + "px");
isilverlightControlHost.SetStyleAttribute("position", "absolute");
All of this code works fine in Internet Explorer, Crome, and Safari, but the " Continue " doesn't show up in FIREFOX only.
So is there a problem with this code?
Sample code: http://lm-bucket-for-forum-post.s3.amazonaws.com/HtMLViewerSilverLight.zip
working example: just replace ".zip" with "TestPage.html" in the above url.
Please let me know how can I solve it?
Thanks in advance, Lakshmilal Menaria
a source to share
I took a look at your code and as I suspected it is not Silverlight, it seems to be the problem, but more CSS implementation across different browsers.
To make this work in both browsers, you need to remove the following line of code:
isilverlightControlHost.SetStyleAttribute("position", "absolute");
Or change the code so that Firefox ignores the position style attribute:
isilverlightControlHost.SetStyleAttribute("position", "absolute !important");
I tried this on my machine using IE8 and FF3.6.12, and the Continue buttons are visible even when this line of code changes.
a source to share