html - Finding the src of an image via Javascript -
i found answer question via simple google search, although, there slight problem ran into.
so far, have image on html page id of newavatar. attempting find image via id, , save it's source variable, xml document used later on.
when save source variable, or alert checking purposes, displaying full source, unusual. example, running site on wamp server, variable saving as:
http://localhost/uploads/newuploadedimage.jpg
when in reality, source should plain , simple, uploads/newuploadedimage.jpg
the image tag is
<img src="uploads/newuploadedimage.jpg" width="60px" height="60px;" id="newavatar"/>
the way checking source is
alert(document.getelementbyid('newavatar').src);
any idea how rid of first lot of junk?
all appreciated!
by using @davidthomas comment before, managed working. changed alert to:
alert(document.getelementbyid('newavatar').getattribute('src'));
Comments
Post a Comment