CSS and TWebbrowser delphi

后端 未结 2 1313
栀梦
栀梦 2021-01-07 03:08

I was wondering if it was possible to manipulate the CSS of websites. For example color in the input fields? I had a look at several questions, but its not clear to me if it

相关标签:
2条回答
  • 2021-01-07 03:23

    Using @jasonpenny's answer to add a stylesheet, what you need next to change the border around the input element that has focus, is what in CSS is called the focus pseudo class or selector. For more information see these articles:

    • http://www.w3schools.com/css/css_pseudo_classes.asp
    • http://www.w3schools.com/css/sel_focus.asp
    • http://www.w3schools.com/css/css_border.asp

    The http://www.w3schools.com site has a wealth of information on web development. It also allows you to play with many examples so you can see what the effects would be when you change things. If you are trying to learn how to do css styling you might be better of getting to grips with all the information there, instead of trying to learn programming and a programming language at the same time.

    0 讨论(0)
  • 2021-01-07 03:38

    It is possible to modify CSS by adding a stylesheet from code, after the page is loaded:

    var
       document: IHTMLDocument2;
       stylesheet: IHTMLStyleSheet;
       stylesheetIndex: Integer;
    begin
    
       // Inject CSS Style Sheets
       document := webBrowser1.Document as IHTMLDocument2;
    
       stylesheetIndex := document.styleSheets.length;
       if stylesheetIndex > 31 then
          raise Exception.Create('Already have the maximum amount of CSS stylesheets');
    
       stylesheet := document.createStyleSheet('', stylesheetIndex);
       stylesheet.cssText := ...
    
    
    0 讨论(0)
提交回复
热议问题