asp.net window.open()问题

来源:百度知道 编辑:UC知道 时间:2024/06/17 03:37:37
string ImgPath=((System.Web.UI.WebControls.Image)e.Item.FindControl("Image2")).ImageUrl;
string url=@"http://localhost/MCD/"+ImgPath;
Response.Redirect(url);
这样可以定向到一个显示图片的页面,
换成Response.Write("<script>window.open('"+url+"')</script>");
后 虽然可以弹出新页面,但不能显示图片,而且地址栏有乱码:
http://localhost/MCD/Image.jpg
http://localhost/MCD/Image.jpg

找不到网页
正在查找的网页可能已被删除、重命名或暂时不可用。

怎么回事呢?

可以将 url 的路径改为绝对路径再试一次,
绝对路径使用该站点的页面文件所在目录的根目录【站点更目录的文件夹的名称】的路径,
最好不要使用 “http://localhost/”开头的路径。