"Sharad Gupta" <g_******@yahoo .com> wrote in message
news:7e******** *************** ***@posting.goo gle.com...
i have this problem of capturing the filename on the instance when
onclick is activated in the <body>
the function should catch the filename and display it.
Second problem, i have to catch the image name in the same fashion
using =onclick showimage(this) . Is this possible at at
I have tried all combinations of
document.getEle mentbyId();
document.getEle mentbyName();
document.getEle mentbyTagName() ;
document.img[].src();
pls help
Will this help? Watch for word-wrap.
<html>
<head>
<title>show.htm </title>
<script type="text/javascript">
function showfile() {
var pathname = location.pathna me;
var filename =
pathname.substr (pathname.lastI ndexOf("\\")+1, pathname.length );
alert(filename) ;
}
function showpath() {
var pathname = location.pathna me;
pathname = pathname.substr (1,pathname.len gth);
alert(pathname) ;
}
function showimage(that) {
alert(that.name );
}
</script>
</head>
<body>
<input type="button" value="Path+Fil e" onclick="showpa th()">
<input type="button" value="File Only" onclick="showfi le()">
<img src="http://www.google.com/images/logo.gif" name="Google"
onclick="showim age(this)">
</body>
</html>