I'm new to this code and inherited it in my website. Now I have to do some modifications and am not sure how to proceed. I'm allowing the user to upload images and am displaying them in the editor. There are two things that can happen:
1) The image is small and I can display it in the image as-is. No problem, I simply paste it in:
'Insert the image window.opener.document.getElementById("message").contentWindow.focus();
window.opener.document.getElementById("message").contentWindow.document.execCommand('InsertImage', false, '<% = strTheInsertImage %>');
window.close();
2) The image is too big, so I generate a thumbnail image and insert that, then put in a link to the actual image that they can click on:
'Insert the thumbnail window.opener.document.getElementById("message").contentWindow.focus();
window.opener.document.getElementById("message").contentWindow.document.execCommand('InsertImage', false, '<% = strTheInsertImage %>'); window.close();
'Build up the string that reflects the full image rez and links to it! strViewString = "Full Wallpaper View : " & (HTML LINK TO IMAGE HERE) window.opener.document.getElementById("message").contentWindow.focus(); var htmlLink = window.opener.document.getElementById("message").contentWindow.document.selection.createRange()
htmlLink.pasteHTML('<% = strViewString %>');
window.opener.document.getElementById("message").contentWindow.document.execCommand('paste', false, ''); window.close();
The operation in option 1 works great. The image pastes in and the insertion cursor is right behind it. Just like I want.
The operation in option 2 doesn't work right -- The first time you insert the image and link, it looks OK but the cursor ends up BEFORE the image. If you do a second insertion, the second image inserts at the START of the editor window and the second link ends up at the END of the editor window:
[Image2] [Image1] [Link1] [Link2]
Obviously, I'm doing something wrong when I paste in the HTML link because the cursor ends up in the wrong place. Subsequent insertions are fouled up.
How can I control where the insertion cursor ends up after I paste in the HTML linkage so that subsequent operations go in behind the HTML link?
Suggestions appreciated -- As I said, I'm new to this and am having a hard time finding documentation on this. This is code that was in place in my application and I'm just reworking it somewhat.
|