Library clips

sharing ideas thoughts and feedback

May 21, 2006

Bookmarklet or hot key to generate a character string

Filed under: blogs, tools

I’ve always wanted links in my posts to open in a new window, and today I finally bothered to work out how this is done, it took me 2 seconds to find that this is all it takes: target=_blank.

eg. <a href="http://www.google.com" target=_blank>Google</a>…you get this, Google.

This is very handy, how many times have you forgotten to right-click “Open in new window”, and you click on the link and it opens in the same browser, then you have to remember to use the back button to get to the earlier page…when you doing lots at once you may forget about this earlier page.

Anyway the purpose of this post is that the quick tags in my draft blog posts don’t include the “target=_blank”
…what happens is I highlight a word, click on the [link] quick tag, and a box pops up, I enter the link and it wraps it around my word, simple…but I want a [link] quick tag that includes the extra stuff.

I don’t want to type it in manually everytime, so I was thinking if there is a bookmarklet that I could use instead of the quick tag in my blog.

Or at the least, if I could hit the bookmarklet and it would pop up a box with the string: target=_blank, then I could just copy and paste this.

I wonder if there is a tool where you can program a key on your keyboard to type a word when you press it
…this way I could make my hyperlink as usual, but then move the cursor to just before the “>” , in …>Google</a>
and press the special key.

[ADDED: The way I was able to show raw code in this blog post was by using centricle encode/decode, this is one of my tool kit essentials.]

7 Comments »

The URI to TrackBack this entry is: http://libraryclips.blogsome.com/2006/05/21/bookmarklet-or-hot-key-to-generate-a-character-string/trackback/

  1. I use the Signature Firefox extension for this:
    http://www.grim-world.com/miek/

    You can also use the BBCode extension:
    https://addons.mozilla.org/firefox/128/

    Comment by Stefan Svartling — May 21, 2006 @ 9:47 am

  2. John,

    Do you have access to a post template? If you do, then you could save the link code with the target there? Otherwise you can use a base tag to set “open in a new window” as the default for your whole page, & then override any “same window” links with their own target tag?

    Comment by John — May 21, 2006 @ 6:20 pm

  3. NewWindow

    Thanks for the inspiration. I’ll be using that myself. It’s made without www just because I have an asthetic aversion to including the wwws myself. Hacked together from the tagging bookmarklets I altered on http://marshallk.com/bookmarklets

    Hopefully this will work!

    Comment by Marshall Kirkpatrick — May 21, 2006 @ 7:23 pm

  4. Thanks Marshall it works!

    Just working out how to fine tune this process for my purpose when blog drafting.

    Only thing is that the label defaults to the name of the URL you type in…is there a way to type in the URL, and also type in the label?

    Then the problem is that I already have the label (word/phrase) in my blog post…as I usually just highlight it click the [LINK] tag, enter a URL, and submit, which wraps the code around the label.

    I suppose I could cut the word/phrase from my blog post, hit the bookmarklet, paste in the word/phrase, also enter in a URL, then submit, then copy this generated code into the exact spot my cursor is flashing in my blog post.

    Another alternative is to use my blog editor [LINK] tag as per usual, the only thing as we know is that the “new window” part of the code is missing, so I could just hit a bookmarklet and it pops up a box with the pre-populated code: target=”blank”, I can just copy this into my blog post
    …actually I can kind of do this at the moment anyway, just hit the bookmarklet, and type in any random key and hit OK, then I just copy the section: target=”blank”, and paste that into my blog post.

    Comment by Johnt — May 22, 2006 @ 3:01 am

  5. I asked my blog host about this and they suggested to put a check box at the top of my blog, if a person checks this, all links will open in a new window.

    In order to do this they offered some code to go in my template…I’m not sure I’ll use this as it still doesn’t help people that read the feed version of my content.

    Here is an example of a using this.

    Comment by Johnt — May 23, 2006 @ 2:50 am

  6. Maybe a greasemonkey script can enable us to add a button on our blog editors, check out this one to add technorati tags to your blog posts

    http://loucypher.wordpress.com/2005/12/27/technorati-tags-button/

    Comment by Johnt — May 25, 2006 @ 2:34 am

  7. If anyone is interested, someone passed on a code to me…when you are now on my blog, you can check a box, and all hyperlinks will open in a new window.

    NOTE: This does not help when reading the feed version.

    This goes before the /head tag:

    <script type="text/javascript"><!–
    // thanks to randomwalks.com for this code
    function targetLinks(boNew) {
    if (boNew)
    where = "_blank";
    else
    where = "_self";
    for (var i=0; i<=(document.links.length-1); i++) {
    document.links[i].target = where;
    }
    }
    // –>
    </script>

    And whack this in where you want it:

    <form class="hid" name="targeter" action="">
    <p><input type="checkbox" name="targetbox" id="tcheck"
    onclick="targetLinks(this.checked);" />
    <label for="tcheck">
    <font size=1>Open in New Window</font>
    </label></p>
    </form>

    Comment by Johnt — June 4, 2006 @ 2:29 pm

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.

Please note that comments are moderated and will                  not therefore appear immediately.
                    Please do not repost.


Library clips
Library clips Subscribe by Email                                                    

Get free blog up and running in minutes with Blogsome | Theme designs available here