Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Cursor positioning?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Forum LockedCursor positioning?

 Post Reply Post Reply
Author
Klankster View Drop Down
Newbie
Newbie


Joined: 10 June 2007
Location: United States
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote Klankster Quote  Post ReplyReply Direct Link To This Post Topic: Cursor positioning?
    Posted: 25 June 2008 at 8:56am
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.


Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.