代码之家  ›  专栏  ›  技术社区  ›  Darkerstar

在Delphi的twebbrowser中使用jquery UI框架

  •  8
  • Darkerstar  · 技术社区  · 16 年前

    我正在开发一个应用程序,很多UI元素将在twebbrowser中。所以我想我添加了一个jquery用户界面以使它对我来说更容易。

    我可以插入jquery和ui javascript文件,这要归功于 http://www.jasontpenny.com/blog/2008/11/21/jquery-in-a-twebbrowser-in-a-self-contained-delphi-app/

    我一直在做样式表,是的。

      doc2 := Web.Document as IHTMLDocument2;
      doc2.createStyleSheet(FileProtocol(AppPath( 'templates\css\' + JQueryUITheme + '\jquery-ui-1.7.1.custom.css')), 0);
      // FileProtocol and AppPath are to return a current application path and converted to FileProtocol URL format.
    

    javascripts运行良好,但我无法使图像工作。我还尝试用字符串替换所有图像引用,但没有结果。

     stylesheet.cssText := StringReplace(stylesheet.cssText,
        'url(images/','url(' + FileProtocol(AppPath('templates/css/' +
        JQueryUITheme + '/images/')), [rfReplaceAll]);
    

    有人试过类似的东西吗?

    3 回复  |  直到 16 年前
        1
  •  7
  •   jasonpenny    16 年前

    运行一个快速测试,这似乎有效。

    您确定FileProtocol()和AppPath()正常工作吗?

    这些似乎对我有用:

    function FileProtocol(const s: String): String;
    begin
       Result := 'file:///' + StringReplace(s, '\', '/', [rfReplaceAll]); // '
    end;
    
    function AppPath(const s: String): String;
    begin
       Result := IncludeTrailingPathDelimiter( ExtractFilePath(Forms.Application.ExeName) ) + s;
    end;
    

    [更新]

    我从主页下载链接下载了jquery用户界面[ Current (stable) ],并从中获取动画图像 http://jqueryui.com/demos/progressbar/#animated

    参见Github上的演示项目: http://github.com/jasonpenny/democode/tree/057f0ad22fc5c3272909de346b6e67b0444d8981/JQueryUIProgBar

        2
  •  1
  •   Stijn Sanders    16 年前

    你的HTML有 <base href="" /> 标签?因为看起来相对的路径是错误的。

        3
  •  -1
  •   Hugo    13 年前

    访问cgdevtools,他们有一个jquery组件套件可用于IntraWeb。