无 Windows 属性仅在 Firefox 中不起作用
我创建了一个简单的 silverlight 应用程序来实时显示 xml 中的一些文本。使用 HTML DIV 标签显示文本。我添加了插件属性 windowless=true、enablehtmlaccess=true、background=transparent。
在 Silverlight 上,我在顶部和底部添加了一个按钮“继续”。底部,显示有关该单击的一些消息。
Silverlight 插件根据 XML 内容调整大小。
我的代码:
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:
在应用程序上创建 HTML DIV 开始使用:
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);
设置 XML 文本:
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 插件大小增加代码:
isilverlightControlHost.SetStyleAttribute("height", HtmlPage.Window.Eval("document.documentElement.scrollHeight").ToString() + "px");
isilverlightControlHost.SetStyleAttribute("position", "absolute");
所有这些代码在 Internet Explorer、Crome 和 Internet Explorer 中都运行良好。 Safari,但“继续”仅在 FIREFOX 中不可见。
那么这段代码有什么问题吗?
代码示例:http://lm-bucket-for-forum -post.s3.amazonaws.com/HtMLViewerSilverLight.zip
工作示例:只需将上述 URL 中的“.zip”替换为“TestPage.html”即可。
请让我知道如何解决?
提前致谢, 拉克斯米拉尔·梅纳里亚
I have created a simple silverlight application to display some text at realtime from xml. The text display using HTML DIV tag. I have added plugin property windowless=true, enablehtmlaccess=true,background=transparent.
On Silverlight I have added a Button "Continue" at Top & Bottom, which shows some message on that click.
Silverlight Plugin resize based in XML contents.
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:
Creating HTML DIV on 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);
Set the 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 size increase code :
isilverlightControlHost.SetStyleAttribute("height", HtmlPage.Window.Eval("document.documentElement.scrollHeight").ToString() + "px");
isilverlightControlHost.SetStyleAttribute("position", "absolute");
All these code is working fine in Internet Explorer, Crome & Safari but "Continue" not visible in FIREFOX ONLY.
So is there any issue with this code ?
Code Sample :http://lm-bucket-for-forum-post.s3.amazonaws.com/HtMLViewerSilverLight.zip
working sample : Just replace ".zip" with "TestPage.html" in above URL.
Please let me know how can I solve it ?
Thanks in advance,
Laxmilal Menaria
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我查看了你的代码,我怀疑这似乎不是 Silverlight 的问题,而更多的是不同浏览器中 CSS 的实现。
要在两种浏览器中都可以使用此功能,您需要删除以下代码行:
或修改代码,以便 Firefox 忽略位置样式属性:
我已在我的计算机上使用 IE8 和 FF3.6.12 以及继续按钮在两者中都可见。
I have taken a look at your code and as I suspected its not Silverlight that seems to be the issue but more the implementation of CSS within the different browsers.
To make this work in both browsers you either need to remove the following line of code:
Or amend the code so that the position style attribute is ignored by Firefox:
I have tried this on my machine using IE8 and FF3.6.12 and the Continue buttons are visible in both when this code line is changed.