1. Javascript: Insert text at the cursor point

    jake on 2005.05.22
    at 11:34 pm

    One of the things that’s more difficult than it ought to be around here is adding images to posts. At least when it comes to remembering the steps.

    What I worked up the other day is some javascript to make it a little simpler. First I added a little call to only show the alt and title fields when adding images. And I added a little link to put the correct image tag into the textarea.

    The only problem was the simplest script can only throw the element in at the end of the text or replace the text completely. Through good old Google I found a script that Alex King discovered and posted to do exactly what I wanted. So now we have a script to insert the image element where your cursor is.

    But I had already built a variable along with adding in onfocus=";" to all the textareas to set the variable. In this case the main article and the excerpt. So I modified the javascript to use the variable and getElementById to paste the code into the correct textarea.

    It’s not a very complex little group of scripts but it adds in a nice little feature to our home grown system. And hopefully this can help someone else out there.

    Posted in: Web


    Comments (3)

    1. brian said on 2005.05.25 at 12:56 am


      It’s a real shame y’all can’t see the really cool work Jake’s done behind the scenes to make this place exist, once a figment of my imagination, a reality, fully hand rolled, and with some easy to use, fast and light features. Big ups to Jake.

    2. George said on 2005.05.26 at 10:39 pm

      If you use Flickr to host your images, the procedure for posting images to your blog is not too hard once you get it set up. You might find my blog helpful.


    3. jake said on 2005.05.30 at 02:12 pm

      Thanks George

      I actually am using Flickr on my friend’s Blogger account.

      Her site Surviving Your 20’s uses direct links for the layout images. And I set up a private group for the images on the left side.

      I’ll have to write an actual post about the sites I’ve been working on lately huh?

    Comments have been automatically disabled to curtail spam.

by date

« May 2020 »
Sun Mon Tue Wed Thu Fri Sat
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30