Hi, I am new! I use this html to get a image from the webserver: <img src=”mypic.php?uid=5555″ … > I have named the imagefile with ‘abcd.gif’ via writing it in the http response header. But can I get it(‘abcd.gif’) by use of javascript and how to? Thanks in advance!
@toicontienFeb 05.2009 — #You could add the image name to the query string in the src attribute: [CODE]<img src="mypic.php?uid=5555[B]&filename=abcd.gif[/B]" [B]id="myImage"[/B] ... />[/CODE] Then search the web for a JavaScript function that reads query strings. [CODE]var img = document.getElementById("myImage"); var imgName = /* pass img.src to a function that reads a query string, extract filename */;[/CODE] Also, for XHTML, the slash before the ">" character on an <img> tag should be a forward slash, not a back slash.
But I cant add this param--'filename=abcd' in the request url... because the image name abcd is generated by serverside(it depend on the image which is fetched back). For example, if the request is legal, the back image name is 'abcd', and if not the image name is 'error'.
'On the other hand, maybe you could make an AJAX request for that image, and then you can read the HTTP headers. ' --- I think what you said is the only way for my need! I will do it like you said!