I want to adapt the following script as a custom insert image dialog in my WYSIWYG editor, but I can’t get it to write an image tag correctly.
<head>
<script>
function getImageDims(imgurl)
{
var oImage = new Image();
oImage.onload = new Function(
‘iView.document.write(“<img src=’+imgurl + ‘ width=”+this.width + ” height=”+this.height)’
);
oImage.src = ‘file:///’ + imgurl;
}
</script>
</head>
<body>
<input type=”file” name=”load”> <input type=”button” value=”Get Image Data” onclick=”getImageDims(load.value)”>
The above produces the following image tag:
<img src=C:WINDOWSDesktopme.jpg width=100 height=148
Don’t know why there are no /s in the url since they are displayed in the browse text field. And when I try to place a space between the url and the image name and add a > to close the tag, I just keep getting one javascript error message after another: object expected onclick, invalid whatever, etc.
Can this script be salvaged to write a proper image tag? Whatever I change screws it up.