Posts Tagged ‘jQuery’

Open link in a new window in XHTML 1.0 Strict June 24, 2009 No Comments

As you may notice using target=”_blank” breaks XHTML 1.0 Stric validation. And here you are a solution with jQuery:

Add rel=”external” for links that you want to be opened in a new window
Include the following jQuery script:

$(function() {
  $("a[rel*='external']").click(function() {
    window.open($(this).attr(‘href’), ‘external’, ”);
  });
});

But I agree that it’s annoying when link is opening in new [...]

Focus element in ThickBox March 24, 2009 No Comments

I faced with a problem focusing element in thickbox popup. I open login form using thickbox and want to take a focus on the first element of the form. Though the following code does look to be working:

$(document).ready(function() {
    $("input[name='username']").focus();
});

But there is a little trick. If you make a small 100ms delay in focus() [...]