document.write(" <img id="pic" src='" + filePath + "' width=144px height=115px />"); alert(document.getElementById("pic").src)
document.write(" <img id="pic" src='" + filePath + "' width=144px height=115px />"); alert(document.getElementById("pic").src)
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<%=path%>就可以显示路径
这不行~~
因为我有个循环打印了若干个~~
for(var i=0 ; i<4 ; i++){
document.write(" <img src='" + filePath + "' width=144px height=115px />");
}如果这样的话每次得到的只是第一张的~~
我要得到我选中的那一章的src~~
谢谢您的回答~
function showimg(value){
alert(value);
}
document.write(" <img src='" + filePath + "' width=144px height=115px onclick="showimg(this.src)" />");
那我不就要写100个getElementById?
{
e=e||event;
var tag=e.target||e.srcElement;
if(tag.tagName=="IMG")alert(tag.src);
}
document.write(" <img src='" + filePath + "' width=144px height=115px />"+"onclick='alert("+this.src+")'");
}
function show(value){
alert(value);
}
for(var i=0 ; i <4 ; i++){
document.write(" <img src='" + filePath + "' width=144px height=115px />"+"onclick=show(this.src)");
} 试试看:
(:D
我的意思是我的页面上有很多张图片!!
我点击某张图片的时候就获得这张图片的src=""~~
TMD什么机顶盒的破浏览器?
我写成这样,取不出来~~
for(var i=0 ; i <fileNames.length ; i++) {
fileName = fileNames[i];
document.write("<img src='" + filePath + "' width=144px height=115px onclick='getImageSrc(this)'");
} function getImageSrc(img)
{
var test=img.src;
alert(test);
}
我写成这样,还是取不出来~~ JScript code
for(var i=0 ; i <fileNames.length ; i++) {
fileName = fileNames[i];
document.write("<img src='" + filePath + "' width=144px height=115px onclick='getImageSrc(this.src)'");
} function getImageSrc(src)
{
// var test=img.src;
alert(src);
} 靠~~
在IE都可以~~
真TMD的烂浏览器~~~