Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

image tag script 1

Status
Not open for further replies.

starrwriter

Programmer
Jun 16, 2004
8
US
Can anyone tell me how to stop the script below from removing the back slashes in the image URL? Here's the result I get in the alert:

<img src=C:WindowsDesktopimage1.jpg width="100" height="100" border="0">

function getImageDims(imgurl)
{
var oImage = new Image();
oImage.onload = new Function(
'alert("<img src='+imgurl + ' width="+this.width + " height="+this.height + [" border=0>"])'
);
oImage.src = load.value;
}
</script>
</head>
<body>
<input type="file" name="load"> <input type="button" value="Get Image Data" onclick="getImageDims(load.value)">

The URL is displayed correctly with slashes in the <input type="file" text field, but the script changes load.value by removing the slashes.
 
Try this:
Code:
<img src="C:\Windows\Desktop\image1.jpg" width="100" height="100" border="0">
<script>
function getImageDims() {
var oImage = new Image();
oImage.onload = imgOnload;
oImage.src = load.value;
}
function imgOnload() {
alert("<img src='"+load.value+"' width='"+this.width+"' height='"+this.height+"' border='0'>");
}
</script>
</head>
<body>
<input type="file" name="load"> <input type="button" value="Get Image Data" onclick="getImageDims()">
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top