I want to adapt the following alert script into an insert image dialog
in my WYSIWYG editor, but I can't get it to write an image tag
correctly.
<head>
<script>
function getImageDims(im gurl)
{
var oImage = new Image();
oImage.onload = new Function(
'alert("<img src='+imgurl + ' width="+this.wi dth + "
height="+this.h eight)'
);
oImage.src = 'file:///' + imgurl;
}
</script>
</head>
<body>
<input type="file" name="load"> <input type="button" value="Get Image
Data" onclick="getIma geDims(load.val ue)">
The above produces the following image tag:
<img src=C:WINDOWSDe sktopthumbnail. jpg width=100 height=148
Although the URL is displayed correctly in the browse text field named
"load," the onclick function fails to copy it correctly with the
slashes in place. And when I try to add a > to close the image tag, I
get error message "object expected" in the onclick line.
Any ideas on how to salvage this script? The pattern of single and
double quotes in the alert line doesn't make any sense to me and every
time I alter one quote I get an error message.
in my WYSIWYG editor, but I can't get it to write an image tag
correctly.
<head>
<script>
function getImageDims(im gurl)
{
var oImage = new Image();
oImage.onload = new Function(
'alert("<img src='+imgurl + ' width="+this.wi dth + "
height="+this.h eight)'
);
oImage.src = 'file:///' + imgurl;
}
</script>
</head>
<body>
<input type="file" name="load"> <input type="button" value="Get Image
Data" onclick="getIma geDims(load.val ue)">
The above produces the following image tag:
<img src=C:WINDOWSDe sktopthumbnail. jpg width=100 height=148
Although the URL is displayed correctly in the browse text field named
"load," the onclick function fails to copy it correctly with the
slashes in place. And when I try to add a > to close the image tag, I
get error message "object expected" in the onclick line.
Any ideas on how to salvage this script? The pattern of single and
double quotes in the alert line doesn't make any sense to me and every
time I alter one quote I get an error message.
Comment