Network Information API

How to detect Network Connection changes ??

Do you have same question sometime in ur mind ? hmm.. i got answer from MDN

This API provides information about the system’s connection, such as connection bandwidth of user device, or whether the connection is metered.

Usage :
This can be used to select hight definition and low definition content based on the user’s connection.

Detecting connection changes

var connection = navigator.connection || navigator.mozconnection 
|| navigator.webkitconnection;
function updateConnectionStatus(){
alert("connection bandwidth="+connection.bandwidth +"Mbs");
if(connection.metered){
alert("the connection is metered");
}
}
updateConnectionStatus();

Simple JS Code ..!!@@

Add Google Search-box on your static website

hey guys,

today i integrate Google search box widget in my website which is very useful to add search functionality in our static website.

here is step for adding google widget in your website.

Go to Google Custom Search http://www.google.com/cse/

Click on Create a Custom Search Engine

Give it a name, enter sites you want to cover with the search.

Complete the process and get the javascript. Integrate the script into your static page.

Screenshot:

google search box

you can also customize this widget using different layout options. for example i want to display search result in new window tab. so i customized my code like

<gcse:searchbox-only newWindow=true></gcse:searchbox-only>

newWindow=true

visit Custom Search Element Control API for more information.

hope you like this post 🙂

ASCII Code application(write in ASCII code)

hey guys,

open this file in browser and write anything in ASCII code, this is really nice application, which is used for any purpose.

i developed this application for my project purpose. and the best thing about this application is backspace also working as usual to delete last character.

so lets go for coding..

note : here i include online jquery file.. so to run this application internet must be there, or you can download js file and give link here.


<!DOCTYPE html>
<html>
<head>
<script src=”http://code.jquery.com/jquery-latest.js”></script&gt;
</head>
<body>
<p id=”t1″></p>
<script>
var keycode=0;
var k;
var temp;
var len;
var totallen,sublen;
var str=””;
document.onkeyup = function(e){
keycode = window.event.keyCode;
if(keycode == 8)
{
var data = document.getElementById(“t1″).innerHTML;
totallen = data.length;
sublen = totallen-len;
str=””;
for(var i = 0;i<sublen;i++)
{
str += data.charAt(i);
}
data = str;
$(“p”).empty();
$(“p”).append(str);

}
else
{
k = keycode;
temp = k.toString();

len = temp.length;
$(“p”).append(keycode);
}
}
</script>
</body>
</html>


hope you like this application!!

sending data with +sign in url

 

hello guys,

today , i got one problem

i had to send one variable through url to next page and i was fetching that variable using _GET[‘variablename’] but i couldn’t got proper value. because variable contains + sign say(b+).

code with problem

var url="searchCity.php?c="+bg;

Solution

if any variable contains + sing or other sign then use encodeURIComponent() function to encode url.

correct code

var url="searchbg.php?c="+ encodeURIComponent(bg);

Now you get full value of variable with +sign.!