Archive for May, 2009

Transperent div for all browser

if (b.ie)
{
var filter = this.element.style.filter.replace(/alpha\s*\(\s*opacity\s*=\s*[0-9\.]{1,3}\)/, ”);
this.element.style.filter = filter + ‘alpha(opacity=’ + parseInt(ht * 100, 10) + ‘)’;
}
else
{
this.element.style.opacity = ht;
}
this.element.style.visibility = ‘visible’;
this.element.style.display = ‘block’
}

Get location from IP address in Ruby On Rails for free….

Find below the code for finding location from IP address using IP location tools.
require ‘net/http’
require ‘rexml/document’
include REXML

class MapsController < ApplicationController
def index
@location = locateIp()

end

def locateIp
ip = request.remote_ip
ips = ip.to_s
url = “http://iplocationtools.com/ip_query.php?ip=”+ips

xml_data = Net::HTTP.get_response(URI.parse(url)).body

xmldoc = REXML::Document.new(xml_data)

# Now get the root element
root [...]