1. November 2010 18:24
The following are a few techniques you can use to target specific IE versions via CSS markup.
TAGIDENTIFIER {
property: valueA; /* all browsers, of course */
property: valueB\9; /* IE9 and below, the 9 has nothing to do with the version in place */
*property: valueC; /* IE7 and below */
_property: valueD; /* IE6 */
}
/* IE6 ONLY */
* html TAGIDENTIFIER
/* IE7 ONLY */
*:first-child+html TAGIDENTIFIER
/* Modern Browsers & IE7+ */
html>body TAGIDENTIFIER
I would like to point out that using IE conditional comments is still the best way to address specific browsers, it's just worthwhile to know about these techniques.
24. September 2010 15:01
When using JavaScript these days, it is generally a good idea to namespace your javascript methods so that they don't polute the global namespace.
if (typeof mysite == 'undefined') var mysite = {};
mysite.section = mysite.section || {};
mysite.section.subNamespace = mysite.section.subNamespace || {};
mysite.section.subNamespace.component = (function(){ ... }());
This allows you to create a clean separation of your utilization. Although you may not want to go as deep as the example above, you can see
how this could very well become cumbersome when you want to declare one or more namespaces. It would be nice to have a helper method that
lets you simply declare namespaces.
//declare a single namespace
namespace('mysite.section.subNamespace.component');
//declare multiple namespaces at once
namespace('mysite.section2', 'mysite._utilities');
This works out much nicer, and is easier to repeate as-needed when creating your namespaces. The function I am using for this is below.
var namespace = (function(root){
//regular expression to limit formatting of namespaces
var nsre = /^([\$\_a-z][\$\_a-z\d]*\.?)+$/i
//define returned function
return function(ns) {
var args = Array.prototype.slice.call(arguments);
var ret = [];
while (args.length) {
ns = genNS(args.shift());
if (ns) ret.push(ns);
}
if (ret.length == 0) return; //undefined, no valid input
if (arguments.length == 1) return ret[0]; //only a single input, return that namespace
return ret; //used overload for multiple namespaces, return the array/list
}
//private static method to generate a single namespace
function genNS(ns) {
if (!ns.match(nsre)) return;
ns = ns.split('.');
var base = root;
for (var i=0; i<ns.length; i++) {
base[ns[i]] = base[ns[i]] || {};
base = base[ns[i]];
}
return base; //return resulting namespace object
}
}(this));
This functionality is very useful, and is included in a number of API toolkits.
You could replace the var namespace declaration and attach it
to an existing object such as $.ns, which would
attach it to an existing reference.
If you have suggestions for future topics, feel free to leave a comment or
contact me via email.
28. April 2010 14:40
I was reading an article on Google's use of hash-bang in order to provide a consistent means of Ajaxy content for crawling/display. There are three points to resolve here. 1. Handling those cases where someone posts an ajaxy url, with the hash endpoint to facebook or twitter so that the search engines have a convention to handle these types of urls. 2. Being able to deal with the Ajaxy endpoint, the original content and the ajax callback content. 3. Being able to deal with those browsers that don't have scripting.
It got me thinking, how would one could work with progressive URL's via MVC and a few thoughts occurred to me. First, if the controller name is always the first portion of the url from the application base, if the MVC routing engine could simply replace the ?_escaped_fragment_= portion of the uri to be equal to the original route. For example http://mysite/controller/action/1?_escaped_fragment_=/otheraction/2 would be equivalent to http://mysite/controller/otheraction/2 on the backend. Second, How difficult would it be for the default view engine to be transposed in the instances of an expected response type give html, vs js. Similar to how WCF over http handles JSON via the same endpoints as XML. I know this has been discussed in the past.
Where this leads me, is thinking it might be nice to have an ASP.Net MVC 2 based framework, with conventions for handling these scenarios as a default. I like ASP.Net MVC quite a bit, and have followed Castle and Fubu as well. I'm merely thinking that it would be nice if there were a default starter kit towards creating a browser and search engine friendly Ajaxy application. It really isn't easy. I think that the google hash-bang solution leaves out the people that don't have scripting enabled, getting a hash-bang endpoint is near worthless, save for a <noscript>script disabled indexable links here</noscript>. And progressive enhancement (aka Hijax) techniques don't allow for a browser engine to properly index copy/pasted urls. Having some level of convention to support both is necessary. I think it's equally necessary for google to post the _escaped_fragment_ based urls in the search results for those users who have scripting disabled.
13. April 2010 10:59
I've been working on a number of web based applications recently, and have taken to using a few techniques that I thought I would share. I won't be sharing the code so much, which is ASP.Net centric, but will discuss what I am trying to accomplish.More...
17. November 2007 18:07
After reviewing the following recent blog postings (Top 30 popular websites Using CSS and Using Tables), I just want to state my own opinions regarding Tables vs. CSS based design. More...