|
Moderator

| Joined: | 23 Sep 2002 | | Posts: | 949 | | Location: | St. Louis, MO |
|
 |
Posted: Thu Jun 17, 2004 8:07 am |
|
 |
 |
 |
 |
To JavaScript, "\" is a special character referred to as Escapse. It is used to indicate that the next character is something special. So to indicate that the \ is the one you want, you have to escape it like \\. Before you submit if you were to go through and put in \\ wherever there is a \, it would work. This is the same for all C languages.
Yeah, it is a pain to have to go through and manually fix the \ so, to make it easier, you need to use a replace statement as I did below. It uses regular expressions which is a totally different topic. The four slashes are actually two sets of \\.
<SCRIPT LANGUAGE="JavaScript">
function getImageDims(imgurl)
{
imgurl = imgurl.replace(/\\/g, "\\\\");
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)"> |
|
|
_________________ Sometimes you feel like a nut, and sometimes you don't.
|