Here is a small script that utilizes the JavaScript location.hash property to handle the broken back and forward browser buttons in AJAX websites.
For the demo we need is a simple AJAX callback function, the hash handling function and a couple of HTML pages to include in our one-page website via the XmlHttpRequest.
1. getcontent(file) – the argument of the function is the [...]
Archive for the ‘Tips and Tricks’ Category
CSS Hack for Safari and Google Chrome: Redux
Posted in Browsers, CSS, CSS Hacks, Tips and Tricks, tagged css filters, css hack, google chrome css hack, safari css hack on July 30, 2009 | 3 Comments »
As body:nth-of-type(1) and body:first-of-type are supported by FireFox 3.5x, the hack that I wrote about in this post cannot be used anymore. You may try the following one, which targets only Google Chrome and Safari:
@media screen and (-webkit-min-device-pixel-ratio:0)
{
div
{
color: red; /* The text will appear red only in Safari and Google Chrome */
}
}
The Mystery of c:\fakepath Unveiled
Posted in Browsers, Forms, HTML5, Tips and Tricks, Web Development, tagged c:\fakepath, fakepath, file upload fakepath, HTML5, input type file fakepath on June 9, 2009 | 1 Comment »
Have you tried to manipulate the string that is returned by the value attribute of a file upload input (<input type=”file” />) under Internet Explorer 8? Did you get the strange c:\fakepath string? Relax - there is nothing wrong with your code, and although this is quite confusing, it has its justifiable reasons. Here is a screenshot of a [...]
CSS Hack for Internet Explorer 8
Posted in Browsers, CSS, CSS Hacks, Tips and Tricks, tagged css hack, IE css hack, IE8 css hack, Internet Explorer 8 CSS hack, Internet Explorer 8 hack, Internet Explorer CSS hack on June 4, 2009 | Leave a Comment »
Notwithstanding the improvements in the CSS support in Internet Explorer 8, there may be cases when a CSS hack for that particular browser is necessary. Here is one that works in IE8 Standards Compliance Mode:
.classnameOrElement
{
color /*\**/: blue\9
}
And another one that will be applied in all IE versions:
.classnameOrElement
{
color: blue\9
}
Creating Style Tag with JavaScript and Adding Rules to It
Posted in CSS, JavaScript, Tips and Tricks, tagged create style tag with JavaScript, createElement, createStylesheet, CSS, cssText, dynamic objects, dynamic styles, styleSheet on May 6, 2009 | 1 Comment »
Sometimes, when working with dynamically created objects on the client, it is needed to style these elements in a specific way. Due to the nature of these objects (for example – unique IDs) , they cannot be styled in the classic way, though. The document.createElement method of JavaScript can be used to create <style>…</style> tag and [...]
10 Dirty CSS Tips and Tricks
Posted in CSS, CSS Hacks, Tips and Tricks, Web Development, tagged alpha transparency css filters internet explorer ie ove, CSS, css filters, css hack, css opacity, css tips and tricks, css transparency, css watermark, get css property value, google chrome css hack, IE6 css hack, IE7 css hack, IE8 CSS opacity, max number of css files, safari css hack, transparent border in IE6 on January 6, 2009 | 4 Comments »
Here is a collection of 10 CSS tips, tricks in blogposts I have written during the last year that you may find useful:
01. Better Image Scaling and Resampling in Internet Explorer
02. Setting Opacity and Other Filters in Internet Explorer 8
03. The 32 External CSS Files Limitation of Internet Explorer and More
04. Unobtrusive CSS Loading Indicator for Images
05. CSS: Filtering and Distinguishing Google Chrome and Safari
06. [...]