When you use fancybox, it automatically adds listeners which stop any other use of the Esc, Left and Right keys on your keyboard. The just don’t work in forms etc inside Fancybox.
This isn’t such an issue with the escape key, but not being able to use the left and right, for example in text inputs, is a pain.
The changes below add an additional option to Fancybox called useNextPrev which you can set to false to stop Fancybox adding listeners to these keys. I haven’t included the escape key as I think it’s far less of an issue. Continue Reading… »
Posted by Harry at 11:40 am on June 2nd, 2010.
Categories: Javascript, jQuery.
I love fancybox. It’s a great and flexible jQuery lightbox, but I decided there were a couple of things I needed it to do that it doesn’t, so I dived into the code head first and added a couple of features. Be warned that you need to edit the file jquery.fancybox-1.3.1.js to implement them.
Combined add and fire / show / open
Yes I know you can do this with $.fancybox(content, options)
It’s tough to add the fancybox listener and fire it at the same time, for example onclick or using a live event. That annoyed me in some circumstances. Previously I have resorted to adding fancybox to anchors on hover so it could fire onclick: Continue Reading… »
Posted by Harry at 12:10 am on May 13th, 2010.
Categories: jQuery.
If you are finding you need to use javascript inside an html or xhtml file and it won’t validate, then here is a little tip for you.
If you surround all your javascript with <![CDATA[ and ]]> tags, all will come good.
The CDATA is seen by the validator as data which doesn’t need checking. So this:
<script>
document.getElementById('container').innerHTML('<p>hello</p>');
</script>
becomes this:
<script>
<![CDATA[
document.getElementById('container').innerHTML('<p>hello</p>');
]]>
</script>
Another option is to escape < and > characters server-side / in the file and then unescape with javascript
<script>
document.getElementById('container').innerHTML('<p>hello</p>'.replace('/</','<').replace('/>/','>'));
</script>
Posted by Harry at 1:43 pm on April 21st, 2010.
Categories: Javascript, The Web.
If you love getScript as a shortcut method in jQuery but you hate not being able to control whether the script calls from the browsers cache or not then you can override the build in function with a new one which is backwards compatable, so it won’t break any of your old code, and allows you to choose true or false to caching.
Read the original post by Jamie Thompson
(function($){
$.getScript = function(url, callback, cache){
$.ajax({
type: "GET",
url: url,
success: callback,
dataType: "script",
cache: cache
});
};
})(jQuery)
Posted by Harry at 9:09 am on March 24th, 2010.
Categories: Javascript, jQuery.
Before I get started, I would just like to confirm there is absolutely no reason to change your Twitter password. That’s right. Your password is safe even if you fell for the don’t click scam.
A harmless virus has been seen on Twitter over the last couple of weeks. It manifests itself as a tweet from someone which simply reads ‘Don’t click {link}’
If you are logged into twitter and you click the link, followed by a link on the following page which also reads ‘Don’t click’ then an identical message is posted without your knowledge to your own feed.
Continue Reading… »
Posted by Harry at 7:41 pm on February 12th, 2009.
Categories: Javascript, The Web.