本帖最后由 wanghaicx 于 2011-10-20 16:32:35 编辑

解决方案 »

  1.   

    newsDiv.getElementsByTagName("img");
    然后循环改变img.style.display = "none";
      

  2.   

    ' ============================================
    '函数名:splitArticleContent
    '作  用:利用正则表达式把文章内容里的图片信息去掉,显示文字内容
    '参  数:str ----文章内容
    '        length---显示字符长度
    '返回值:截取后的内容
    ' ============================================
    function splitArticleContent(str, length)
       str = replace(str,"onload=""if(this.width>550){this.width=550;}"" border=0","")
       dim re
       set re=new RegExp
       re.global=true
       re.ignoreCase=true
       re.multiline=true

       re.Pattern="<(.[^>]*)>"
       str=re.replace(str,"")
    str=left(str,length)

    re.pattern="([\s\S]*)(\<[^>]*)"
    str=re.replace(str,"$1$2")

    fAtDg=str
        set re=nothing
    end function
      

  3.   

    用 这个做判断 if instr(MeRs("D_Content"),"<img")>0  then    怎么样写才能不输出图片呀?
      

  4.   


    可以详细一点么? 我是直接 用Response.Write MeRs("D_Content")显示新闻内容的,如果用你的方法,应该怎么写?
      

  5.   

    不是有Code标签吗,这个就不会解析HTML代码了,也就不会显示出来了,很好用的,你试试,如果是.Net,就有一个Literal控件,你试试。
      

  6.   

    <%=splitArticleContent(MeRs("D_Content"),你要显示的长度)%>
      

  7.   

    提示
    错误类型:
    Microsoft VBScript 编译器错误 (0x800A03EA)
    语法错误
    /Function.asp, line 52
    function splitArticleContent(str,length)
      

  8.   


    ' ============================================
    '函数名:splitArticleContent
    '作 用:利用正则表达式把文章内容里的图片信息去掉,显示文字内容
    '参 数:str ----文章内容
    ' length---显示字符长度
    '返回值:截取后的内容
    ' ============================================
    function splitArticleContent(str, length)
      str = replace(str,"onload=""if(this.width>550){this.width=550;}"" border=0","")
      dim re
      set re=new RegExp
      re.global=true
      re.ignoreCase=true
      re.multiline=true  re.Pattern="<(.[^>]*)>"
      str=re.replace(str,"")
    str=left(str,length)re.pattern="([\s\S]*)(\<[^>]*)"
    str=re.replace(str,"$1$2")splitArticleContent=str
      set re=nothing
    end function
      

  9.   

    问题依旧,这串代码 是直接写在服务端<%%>中的吗?需要<script>标签么
      

  10.   


    <%
    ' ============================================
    '函数名:splitArticleContent
    '作 用:利用正则表达式把文章内容里的图片信息去掉,显示文字内容
    '参 数:str ----文章内容
    ' length---显示字符长度
    '返回值:截取后的内容
    ' ============================================
    function splitArticleContent(str, length)
      str = replace(str,"onload=""if(this.width>550){this.width=550;}"" border=0","")
      dim re
      set re=new RegExp
      re.global=true
      re.ignoreCase=true
      re.multiline=true  re.Pattern="<(.[^>]*)>"
      str=re.replace(str,"")
    str=left(str,length)re.pattern="([\s\S]*)(\<[^>]*)"
    str=re.replace(str,"$1$2")splitArticleContent=str
      set re=nothing
    end functionresponse.write(splitArticleContent(MeRs("D_Content"),你要显示的长))
    %>