<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/datejs/1.0/date.min.js"></script>
<script>
function test(){
alert(Date.today().add(3).days());
var n = 6;
var v=n.months().fromNow();
alert(v);
}
</script>
</head>
<body>
<button onClick="test()">Cheak Date addintion..</button>
</body>
</html>
Friday, 18 March 2016
How to make Date addition in JavaScript to get custom date ?
Saturday, 12 March 2016
How to trace your current location useing Gogle map API in brrowser ?
<!DOCTYPE html>
<html>
<head>
<script src = "http://maps.googleapis.com/maps/api/js"></script>
<script>
var dataX='place yr info here..';
//alert(dataX);
function getLocation() {
if (navigator.geolocation){
navigator.geolocation.getCurrentPosition(loadMap);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function loadMap(position){
var lati=position.coords.latitude;
var lang=position.coords.longitude;
var mapOptions = {
center:new google.maps.LatLng(lati,lang),
zoom:17
}
var map = new google.maps.Map(document.getElementById("sample"),mapOptions);
var marker = new google.maps.Marker({
position: new google.maps.LatLng(lati,lang),
map: map,
draggable:false,
icon:"https://lh6.googleusercontent.com/-jceMtMC7nk4/AAAAAAAAAAI/AAAAAAAAABQ/WOlkICkIH7c/photo.jpg?sz=50"
});
marker.setMap(map);
var infowindow = new google.maps.InfoWindow({
content:dataX
});
infowindow.open(map,marker);
}
</script>
</head>
<body onload = "getLocation()">
<div id = "sample" style = "width:100%; height:400px; " ></div>
</body>
</html>
It will work as..
Thursday, 10 March 2016
Use Javascript for custom reload and close browser tab event ....!!
<!DOCTYPE html>
<html>
<body >
<p>Close this window, press F5 or click on the link below to invoke the onbeforeunload event.</p>
<a href="http://plateofcode.blogspot.in/">Click here </a>
<script>
window.onbeforeunload =function(){
return "Write something here...";
};
</script>
</body>
</html>
It will work when you close or reload blog....!!!!
Close this window, press F5 or click on the link below to invoke the onbeforeunload event.
Click here to go to w3schools.com
Wednesday, 9 March 2016
how to use data-attributes in html5?
<html>
<head>
<meta charset="utf-8">
<title>HTML5 data atributes</title>
</head>
<body>
<div id="values"
data-name="Sky"
data-country="India"
data-id="1222">
</div>
<script>
var element = document.getElementById("values");
var dataset = element.dataset;
console.log(dataset.name);
console.log(dataset.country);
element.innerHTML = dataset.name + " is " + dataset.country+"n.....id="+dataset.id;
</script>
</body>
</html>
HTML5 data atributes
Tuesday, 8 March 2016
fun with c program in windows 7..!!
#include<stdio.h>
#include<conio.h>
#include<windows.h>
int main(){
// code for hiding the console_window
HWND stealth; /*creating stealth (window is not visible)*/
AllocConsole();
stealth=FindWindowA("Console WindowClass",NULL);
ShowWindow(stealth,0);
// code for hiding the console_window
while(1){
Sleep(100);
system("msg * heyy sky");
}
return 0;
}
it will work in windows 7 only....run and have fun!!
#include<conio.h>
#include<windows.h>
int main(){
// code for hiding the console_window
HWND stealth; /*creating stealth (window is not visible)*/
AllocConsole();
stealth=FindWindowA("Console WindowClass",NULL);
ShowWindow(stealth,0);
// code for hiding the console_window
while(1){
Sleep(100);
system("msg * heyy sky");
}
return 0;
}
it will work in windows 7 only....run and have fun!!
Saturday, 27 February 2016
How to communicate with browser using Java Socket Program ?
import java.io.IOException;import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
public class SocketTest {
public static void main(String args[])throws Exception{
ServerSocket serverSocket = null;
try {
serverSocket = new ServerSocket(8083);
} catch (IOException e)
{
System.err.println("Could not listen on port: 8083.");
System.exit(1);
}
Socket clientSocket = null;
try {
clientSocket = serverSocket.accept();
if(clientSocket != null)
System.out.println("Connected");
} catch (IOException e) {
System.err.println("Accept failed.");
System.exit(1);
}
PrintWriter out = new PrintWriter(clientSocket.getOutputStream());
out.println("HTTP/1.1 200 OK");
out.println("Content-Type: text/html");
out.println("\r\n");
out.println("<html> <head/> <body> <p> Hello world </p> </body> </html>");
out.flush();
out.close();
clientSocket.close();
serverSocket.close();
}
}
Thursday, 18 February 2016
How to make the browser full-screen in HTML 5 and JavaScript ?
<html> <head> <script type="text/javascript"> function toggleFullScreen() { if (!document.fullscreenElement && // alternative standard method !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFull screenElement ) { // current working methods if (document.documentElement.requestFullscreen) { document.documentElement.requestFullscreen(); } else if (document.documentElement.msRequestFullscreen) { document.documentElement.msRequestFullscreen(); } else if (document.documentElement.mozRequestFullScreen) { document.documentElement.mozRequestFullScreen(); } else if (document.documentElement.webkitRequestFullscreen) { document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); } } else { if (document.exitFullscreen) { document.exitFullscreen(); } else if (document.msExitFullscreen) { document.msExitFullscreen(); } else if (document.mozCancelFullScreen) { document.mozCancelFullScreen(); } else if (document.webkitExitFullscreen) { document.webkitExitFullscreen(); } } } </script> </head> <body> Press this button, <button onclick="toggleFullScreen();">fullscreen my blog</button> </body> </html>
It will work as....
Press this button,
Subscribe to:
Posts (Atom)