Jack @ ASP.NET

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries for the ‘jQuery’ Category

Sticky Footer , fixed footer, pinned footer

1. through css

    #footer {

   position:fixed;

   left:0px;

   bottom:0px;

   height:30px;

   width:100%;

   background:#999;

}

2. jQuery Easy Pinned Footer

http://johnpatrickgiven.com/jquery/pinned-footer/

Sticky Footer , fixed footer, pinned footer

1. through css

    #footer {

   position:fixed;

   left:0px;

   bottom:0px;

   height:30px;

   width:100%;

   background:#999;

}

2. jQuery Easy Pinned Footer

http://johnpatrickgiven.com/jquery/pinned-footer/

jQuery 2.0 will not support IE 6/7/8 any more

This version leaves behind the older Internet Explorer 6, 7, and 8 browsers. In return it is smaller, faster, and can be used in JavaScript environments where the code needed for old-IE compatibility often causes problems of its own. But don’t worry, the jQuery team still supports the 1.x branch which does run on IE 6/7/8. You can (and should) continue to use jQuery 1.9 (and the upcoming 1.10) on web sites that need to accommodate older browsers.

With the release of jQuery 2.0, there are a few environments where the jQuery team will no longer support use of the 1.x line because 2.x is a far better choice. These are typically non-web-site scenarios where support for older IE isn’t relevant. They include:

  • Google Chrome add-ons
  • Mozilla XUL apps and Firefox extensions
  • Firefox OS apps
  • Chrome OS apps
  • Windows 8 Store (“Modern/Metro UI”) apps
  • BlackBerry 10 WebWorks apps
  • PhoneGap/Cordova apps
  • Apple UIWebView class
  • Microsoft WebBrowser control
  • node.js (combined with jsdom or similar)

Break up a Code Line in javascript

You can break up a code line within a text string with a backslash. The example below will be displayed properly:

document.write("Hello \
World!");

However, you cannot break up a code line like this:

document.write \
("Hello World!");

get the selected item text from a ‘select’ html control

it is quite simple via jquery,

$("#yourSelectCtrlId option:selected").text();

[Google Map API] Find a place, and mark it on google map

In google map API, there is a class google.maps.Geocoder, it  is a service for converting between an address and a LatLng.

Demo of using this api:

function showAddress(address){
    var geocoder = new google.maps.Geocoder();
    geocoder.geocode( {‘address’: ‘your address’}, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            var searchLoc = results[0].geometry.location;
            var latlng = new google.maps.LatLng(searchLoc.lat(), searchLoc.lng());
            map.setCenter(latlng);// assert we already have a ‘map’ instance
            marker.setPosition(latlng); // assert we already have a ‘marker’ instance
        }
        else{
            alert("There is no such place!");
        }
    });
}