« September 2007 | Main | November 2007 »
function newWindow(windowName, URL, width, height, scrolling) {
width = width || 400;
height = height || 360;
scrolling = scrolling || 0;
var topX = (window.screen.width / 2) - ( width / 2);
var topY = (window.screen.height / 2) - ( height / 2);
window.open(URL, windowName, 'width=' + width + ',height=' + height +
',location=no,resizable=yes,scrollbars=' + scrolling +
',screenX=' + topX + ',screenY=' + topY);
}
My previous post addressed how to use a client-side script to validate a To:, Cc:, or Bcc: field that may have more than one email address. Since not all people have JavaScript enabled, it's always a good idea to validate on the server as well-- and with multiple emails, you can't just use the function IsValid('email', [field value]) to validate. So, I converted my JavaScript function to ColdFusion code.
Continue reading "Validating multiple emails in one field-- server-side" »
Continue reading "Validating multiple emails in one field" »
It still happens these days that every so often you have to write different code for different browsers-- you might output different form controls for Firefox versus IE, or might write in different stylesheets for older browsers, or you might write out different JavaScripts for IE5 on the Mac. So what's the easiest way to tell which browser and OS is calling your page?
Obviously, you can look through the server's CGI variables too see this information. But you don't want to parse through it every time you have an if-else condition, so I suggest identifying this information once per request or even just once per session with the following code:
<!--- Get the user's platform and browser ---> <cfif CGI.HTTP_USER_AGENT contains "MSIE"> <cfset REQUEST.userAgent = "IE"> <cfelseif CGI.HTTP_USER_AGENT contains "Opera"> <cfset REQUEST.userAgent = "OP"> <cfelseif CGI.HTTP_USER_AGENT contains "Safari"> <cfset REQUEST.userAgent = "SF"> <cfelseif CGI.HTTP_USER_AGENT contains "Netscape"> <cfset REQUEST.userAgent = "NS"> <cfelseif CGI.HTTP_USER_AGENT contains "Gecko"> <cfset REQUEST.userAgent = "MZ"> <cfelse> <cfset REQUEST.userAgent = "NS"> </cfif> <cfif CGI.HTTP_USER_AGENT contains "Mac"> <cfset REQUEST.platform = "Mac"> <cfelseif CGI.HTTP_USER_AGENT contains "Linux"> <cfset REQUEST.platform = "Linux"> <cfelse> <cfset REQUEST.platform = "PC"> </cfif>
Afterwards, you can just refer to REQUEST.userAgent and REQUEST.platform to get the user's environment.
I've posted an update to my microformats CFC today. There are two bugfixes and several XSLT updates (thanks to Gideon Marken for bringing my attention to most of these issues.):
Bug fixes:
You can download the CFC from my microformats CFC project page.