Posted: Thursday 23rd October 2008
Over the past month or so my girlfriend has been talking to me and asking advice about website design, since she’s after progressing her career in the future to become some sort of digital designer or web designer. Pretty neat, eh
Anyway, after talking to one of the designers at my job (I’m not officially a designer, but rather a web developer you see. Oo-er), he asked would she be learning HTML and/or CSS as well. I asked her and she wasn’t too keen on it, but then after looking through numerous job adverts it become apparent that most, if not all, require a website designer to have such skills.
So, then become the task of teaching her the basis of HTML & CSS, which was actually quite fun. She’s picking it up really well, I think, and I’m supprised how quickly she’s picking it up.
I realised, however, there is just so many things to teach when starting out from fresh. One of the things was to use ASCII characters in replacement to just hitting [shift] and a special-character on the keyboard. I explained that using ASCII characters is a safer bet, but most importantly, helps in making the site valid.
Then I thought I would blog about it, posting up here the most common ASCII characters I use, and their code…
« = « = left double angle quotes
» = » = right double angle quotes
© = © = copyright sign
£ = £ = pound sign
& = & = ampersand
Can’t really think of any others I use regularly…? Thought it might help someone anyway, maybe – at least instead of looking through those giant-sized horrible ASCII tables!
Posted: Thursday 23rd October 2008
Following on from Jaspers comment on my blog post regarding my “newly discovered” way of creating new windows on links without using the target=”_blank” attribute, he posted a tidy bit of code based on Mootools that detects all <a> tags on his page, then opens in a new window if it starts with http:// (indicating it being an external link).
That’s cool. So I thought I would do the same using my preferred Javascript framework, jQuery. Here’s my code which has now been implemented on this site & looks like its working just fine…
$('.entry a').each(function(){
if ($(this).attr('href').substr(0,7) == 'http://')
{
$(this).addClass('new-window');
}
});
What we’re doing – top line, cycle through all <a> tags within the .entry class. Secondly, if the first 7 characters of the Href attribute within our <a> tag equals http://, then add a class to the <a> tag called new-window.
This will then be detected by my other small script on my page, as described here. Job done!
Posted: Tuesday 21st October 2008
Making a site XHTML Strict and valid can be a little bit of a challenge at first – especially if like me you’re used to very relaxed and quite frankly, non-valid code!
One of the specific things that I found a little annoying when trying to make this site valid is the fact that target=”_blank” is not valid in the XHTML Strict standards. Eh? How’d you get around that then…
Javascript, or better, jQuery of course
Here’s a bit of jQuery code that I found elsewhere on the ‘net that I thought I should share.
$('a.new-window').click(function(){
window.open(this.href);
return false;
});
Simply dump that into your jQuery document ready function in your JS file.
Then, if you want to open a link in a new window now, instead of using the target=”_blank” method, simply use class=”new-window” on the <a> tag. Sweeeet!