将CSS块动态插入Webbrowser控件中 [英] Dynamic Insertion of CSS block into Webbrowser Control

查看:93
本文介绍了将CSS块动态插入Webbrowser控件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试插入CSS块,以尝试将其插入Web浏览器控件中.我会执行SetAttribute("src","filename.css"),但是网页位于https上,每次都会弹出一个愚蠢的安全异常.

因此,我尝试通过createElement("style")进行尝试,但找不到添加

I have a block of CSS I''m trying to inject into a webbrowser control. I''d do the SetAttribute("src", "filename.css"), but the web page is on https and I get a stupid security exception popping up each time.

So I tried via createElement("style"), but I can find no way of adding the

.autocomplete {
    font-family: Tahoma;
    font-size: 8pt;
    background-color: white;
    border: 1px solid black;
    position: absolute;
    cursor: default;
    overflow: auto;
    overflow-x: hidden;
}
.autocomplete_item {
    padding: 1px;
    padding-left: 5px;
    color: black;
    width: 100%;
}
.autocomplete_item_highlighted {
    padding: 1px;
    padding-left: 5px;
    color: white;
    background-color: #0A246A;
}



元素,因此可以将其附加到head元素.我尝试使用InnerText或InnerHTML时抛出的错误是不支持此属性".这可能是我再次使用错误搜索词的情况,但似乎无法找到解决方案.



to the element so it can be appended to the head element. The error thrown when I try InnerText or InnerHTML is "This property is not supported". This maybe a case of I''m using the wrong search words again, but can''t seem to find a solution to this.

推荐答案

我建​​议您移动将此保存到自己的.css文件中.从那里,您应该能够使用文字控件,例如:

< asp:文字ID ="cssInjector" runat =服务器" Mode ="PassThrough" Text =< link rel =" stylesheet"type =" text/css''media ="all" href =''/YourCssFileReference.css''/>></asp:Literal>

通过将模式指定为直通,文字控件将充当注入点,并将其文本字段直接内联传递.

这应该对您有用,但是我无法验证SSL不会搞乱
I would recommend moving this out to its own .css file. From there you should be able to use a literal control as such:

<asp:Literal ID="cssInjector" runat="server" Mode="PassThrough" Text="<link rel=''stylesheet'' type=''text/css'' media=''all'' href=''/YourCssFileReference.css'' />"></asp:Literal>

By specifying the mode as passthrough the literal control acts as an injection point and will pass its text field straight inline.

This should work for you but I can''t verify that SSL won''t mess it up


这篇关于将CSS块动态插入Webbrowser控件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆