標籤:style color 檔案 資料 width os
前台頁面是這樣的:
<%-- 圖片展示20140705add --%>
<div id="imgShowDiv" style="left:550px; top:90px; height:430px; display:none;" class="msgboxStyle">
<h1 onmousedown="startDrag(this)" onmousemove="drag(this)" onmouseup="stopDrag(this)" style="height: 29px;">
<a id="A1" onclick="closeDlg(this)" href="#" class="iclose" title="關閉或隱藏"></a>
</h1>
<div style="top:30px; position:absolute;">
<a href="" target="_blank" id="aTP_YYZZ">
<img src="" class="jqzoom" style="width: 340px; height: 405px; vertical-align: top; border: 0;" id="imgTP_YYZZ" />
</a>
</div>
</div>
關聯的js為:drag_layer.js和ImgShowFuncs.js,另外還要引用一個imagezoom.css的樣式檔案
點擊圖片時候新頁面開啟原圖但是路徑會報錯,於是我在pageload中添加了第一句話解決之:
Request.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
string args = Request.Params["args"].ToString();
string imgPath = args;
System.IO.FileStream aFile = new System.IO.FileStream(imgPath, System.IO.FileMode.Open, System.IO.FileAccess.Read);
// 建立一個位元據流讀入器,和開啟的檔案關聯
System.IO.BinaryReader brMyfile = new System.IO.BinaryReader(aFile);
// 把檔案指標重新置放到檔案的開始
brMyfile.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);
// 擷取照片的位元組數組
byte[] photo = brMyfile.ReadBytes(Convert.ToInt32(aFile.Length.ToString()));
// 關閉以上new的各個對象
brMyfile.Close();
Response.BinaryWrite(photo);
問題無非就是請求或者返回時候編碼方式不對,寫代碼時候多加註意,出問題多加分析即可。