美文网首页
代码淘沙0622(A-常见题目信息处理js)

代码淘沙0622(A-常见题目信息处理js)

作者: 大风起兮_Seven | 来源:发表于2017-06-22 10:06 被阅读15次

    之前找前端一块联调,优化展示题目信息Html的方法

    NSString *contentStr = model.content;
    contentStr = [contentStr stringByReplacingOccurrencesOfString:@"width" withString:@"wid"];
    // 去除样式
    NSString *htmlContent =[NSString stringWithFormat:@"<style type=\"text/css\">\n"
                            "table{font-size: 14px !important;color: #666 !important;line-height:20px !important;}"
                            "#div123{font-size:14px !important;line-height:20px !important;color:#666 !important;font-family: \"Microsoft Yahei\", \"微软雅黑\";}\n"
                            "    </style>\n<div id=div123>%@</div> <script type=\"text/javascript\">\n"
                            "\t\tvar ele =document.getElementById('div123').getElementsByTagName('*');\n"
                            "\t\tfor(var i=0;i<ele.length;i++){\n"
                            "\t\t\tif (typeof ele[i].getAttribute('style') == \"string\") {\n"
                            "\t                        var str = ele[i].getAttribute('style');\n"
                            "\t                        var box = /font-size:.{2,5}p[xt];{0,1}/;"
                            "\t                        ele[i].setAttribute(\"style\", str.replace(box, \"\"));\n"
                            "\t                    }\n"
                            "\t\t}\n"
                            "\n"
                            "\n"
                            "\t</script>",contentStr];
    [_webView loadHTMLString:htmlContent baseURL:nil];
    

    相关文章

      网友评论

          本文标题:代码淘沙0622(A-常见题目信息处理js)

          本文链接:https://www.haomeiwen.com/subject/gdwxcxtx.html