Jmeter 發測試報告到郵箱,expand/collapse 圖片不顯示

因爲發送到郵箱中html文件是不包含expand/collapse 資源文件的,因此致使郵箱中這兩個圖片沒有顯示,解決方法有兩種:javascript

1. 使用http能訪問的圖片連接地址

  1. 修改change中的圖片資源
function change(details_id) 
{
        if(document.getElementById(details_id+"_image").src.match("http://ww1.sinaimg.cn/large/6fa4e58agy1fgki2i10o8j200g00g03i.jpg"))
        {
            document.getElementById(details_id+"_image").src = "http://ww1.sinaimg.cn/large/6fa4e58agy1fgkhzf6p25j200g00g03d.jpg";
            expand(details_id);
        }
        else
        {
            document.getElementById(details_id+"_image").src = "http://ww1.sinaimg.cn/large/6fa4e58agy1fgki2i10o8j200g00g03i.jpg";
            collapse(details_id);
        } 
}
  1. 修改展現區域中的圖片資源
<td align="center">
        <a href="">
            <xsl:attribute name="href"><xsl:text/>javascript:change('page_details_<xsl:value-of select="position()" />')</xsl:attribute>
            <img src="http://ww1.sinaimg.cn/large/6fa4e58agy1fgki2i10o8j200g00g03i.jpg" alt="expand/collapse"><xsl:attribute name="id"><xsl:text/>page_details_<xsl:value-of select="position()" />_image</xsl:attribute></img>
        </a>
</td>

2. 將圖片轉換成base64

  1. 經過轉換工具將圖片轉成Base64
  2. 修改change中的圖片資源
function change(details_id)
{
        var _dataType=document.getElementById(details_id+"_image").getAttribute('data-type');
        if(_dataType=='expand')
        {
            document.getElementById(details_id+"_image").src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAGUExURSZ0pv///xB+eSAAAAARSURBVAjXY2DABuR/gBA2AAAzpwIvNQARCgAAAABJRU5ErkJggg==";
            expand(details_id);
            document.getElementById(details_id+"_image").setAttribute('data-type','collapse');
        }
        else
        {
            document.getElementById(details_id+"_image").src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAGUExURSZ0pv///xB+eSAAAAAWSURBVAjXY2CAAcYGBJL/AULIIjAAAJJrBjcL30J5AAAAAElFTkSuQmCC";
            collapse(details_id);
            document.getElementById(details_id+"_image").setAttribute('data-type','expand');
        } 
}
  1. 修改展現區域中的圖片資源
<td align="center">
        <a href="">
            <xsl:attribute name="href"><xsl:text/>javascript:change('page_details_<xsl:value-of select="position()" />')</xsl:attribute>
            <img data-type="expand" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAGUExURSZ0pv///xB+eSAAAAAWSURBVAjXY2CAAcYGBJL/AULIIjAAAJJrBjcL30J5AAAAAElFTkSuQmCC" alt="expand/collapse"><xsl:attribute name="id"><xsl:text/>page_details_<xsl:value-of select="position()" />_image</xsl:attribute></img>                   
        </a>
</td>
相關文章
相關標籤/搜索