Trying to manipulate the iframe from a jQuery script running inside the iframe. Here is how to get a handle on the iframe with jQuery when you have id attribute iframe-id-attribute set on the iframe:
var ifr = $( '#iframe-id-attribue', window.parent.document );
Comments Off
Internet Explorer has rendering bugs that vary across all versions. Microsoft has included some conditional comment tags that are specific to their IE browsers since IE5. These are really helpful if you need to include a CSS or JS file to fix layout quirks:
<!--[if IE]> Instructions for all IE browsers <![endif]-->
<!--[if lte IE 7]> Instructions for IE7 or earlier <![endif]-->
<!--[if IE 6]> Instructions for IE6 only <![endif]-->
Comments Off
I just started using the jQuery javascript framework to replace my home-grown animation functions. It is really helpful in speeding up development and is cross-browser compatible so it also cuts down on QA testing. Below is a little bit of jQuery code for swapping out images:
function imgin () {
$( '#img-id' ).attr ( { 'src': new_img_url } );
$( '#img-id' ).load ( function () {
$( '#img-id' ).fadeIn ( 1000 );
} );
}
$( '#img-id' ).fadeOut ( 200, imgin );
Start by setting a 200 millisecond fadeOut on the current image with a callback to imgin function. imgin sets the src attribute (via the attr method) of the image to load the new image file (via new_img_url variable). Then set a load event on the image to trigger fadeIn after the image is loaded.
Links
docs.jQuery.com/Effects
Comments Off
PHP functions for creating and decipering URL-safe strings are urlencode and urldecode.
Javascript functions for creating and deciphering URL-safe strings are escape and unescape.
PHP’s urlencode replaces spaces with + and Javascript’s escape replaces spaces with %20. So if you are decocing a string from PHP with Javascript, you have to replace all the + in the string with spaces using the JS string.replace function. Since + is an operator in Javascript, it has to be escaped with a backslash ( \ ) for the function to execute without error. The g flag has to be included to replace all instances of occurance ( g = global):
string.replace ( /\+/g, ' ' );
Links
urlencode
urldecode
escape
unescape
string.replace
Comments Off
Here is an easy little trick to extrapolate the latitude and longitude coordinates from Google Maps. The coordinates reflect the center of the map so make sure that you have your location centered first. Once you have it all lined up, paste this code into the address bar of your browser:
javascript:void(prompt(”,gApplication.getMap().getCenter()));
Brilliant!
Links
www.tech-recipes.com/google_maps_get_latitude_longitude_values/
Comments Off
The image gallery has been revamped to fit into the new iframe structure of our version 3 site. To check it out, click on the “Archives” link, then “image” link in the sidebar nav.
The animations utilize the Javascript Motion Tween classes written by Philippe Maegerman from Brussels, Belgium. Thanks, Pim!
Links
jstween.blogspot.com
Comments Off
We recently needed to create an HTML page and dynamically hide/show an entire class of <div> tags that were interspersed throughout the page. Using the getElementsByTagName javascript method, we were able to iterate over all of the <div> elements in the document. Then check the CSS class by accessing the className DOM element:
oDivs = document.
getElementsByTagName ( “div” );
for ( d = 0; d < oDivs.length; d++ ) {
cl_name = oDivs[ d ].
className;
if ( cl_name == “bio” ) {
oDivs[ d ].style.display = “none”;
}
}
Note that the getAttribute method does not work in IE since class is a reserved word for IE. Took us a little while to figure that one out.
Comments Off