Find all Programs and practical list here from "labels" !!! For other languages visit - www.kanulp.wordpress.com
Search This Blog
Tuesday, 31 January 2017
Write a javascript program to demo alert box,conditional box and prompt box.
JS Prac 3
<html>
<head>
<title>Practicle 1 JS</title>
<script>
function myf(){
alert("This is an alert box");
}
function mycon(){
var x;
if(confirm("Press Any")==true){
alert("You Clicked Ok !");
}else{
alert("You Clicked Cancel !");
}
}
function myprompt(){
var name = prompt("Enter your name");
if(name){
alert("You Entered "+name);
}else if(name==""){
alert("msg empty");
}else{
alert("you canceled");
}
}
</script>
</head>
<body>
<button onclick="myf()">Alert</button><br/>
<button onclick="mycon()">Confirm</button><br>
<button onclick="myprompt()">Prompt</button>
</body>
</html>
<html>
<head>
<title>Practicle 1 JS</title>
<script>
function myf(){
alert("This is an alert box");
}
function mycon(){
var x;
if(confirm("Press Any")==true){
alert("You Clicked Ok !");
}else{
alert("You Clicked Cancel !");
}
}
function myprompt(){
var name = prompt("Enter your name");
if(name){
alert("You Entered "+name);
}else if(name==""){
alert("msg empty");
}else{
alert("you canceled");
}
}
</script>
</head>
<body>
<button onclick="myf()">Alert</button><br/>
<button onclick="mycon()">Confirm</button><br>
<button onclick="myprompt()">Prompt</button>
</body>
</html>
Write a javascript program to demo of local and global variables.
JS Prac - 2
<html>
<head>
<script>
lname = "Gajjar"; //global
</script>
</head>
<body>
<pre>
1. A variable that is declared inside a function using the var keyword, will have a local scope.
2. A variable that is declared inside a function without var keyword, will have a global scope means acts like a global variable.
</pre>
<script>
var fname = "Karan"; //global
myFunction();
function myFunction() {
var h = "hello"; //local
document.write(h+" "+fname+" "+lname);
}
</script>
</body>
</html>
<html>
<head>
<script>
lname = "Gajjar"; //global
</script>
</head>
<body>
<pre>
1. A variable that is declared inside a function using the var keyword, will have a local scope.
2. A variable that is declared inside a function without var keyword, will have a global scope means acts like a global variable.
</pre>
<script>
var fname = "Karan"; //global
myFunction();
function myFunction() {
var h = "hello"; //local
document.write(h+" "+fname+" "+lname);
}
</script>
</body>
</html>
Write a javascript program to display “hello world” using internal javascript and external javascript.
Practical - 1
Internal JavaScript -
prac1.html
<html>
<head>
<title>Practicle 1 JS</title>
<script>
document.write("Hi this is karan Gajjar");
</script>
</head>
</html>
------------------------------------------------------------------------------------------------
External JavaScript -
pract1(2).html
<html>
<head>
<title>Practicle 1 JS</title>
<script src = "prac1.js">
</script>
</head>
</html>
prac1.js
var str = "Karan Gajjar - Android Developer";
var result = str.link("https://goo.gl/gmzl4t");
document.write(result);
Internal JavaScript -
prac1.html
<html>
<head>
<title>Practicle 1 JS</title>
<script>
document.write("Hi this is karan Gajjar");
</script>
</head>
</html>
------------------------------------------------------------------------------------------------
External JavaScript -
pract1(2).html
<html>
<head>
<title>Practicle 1 JS</title>
<script src = "prac1.js">
</script>
</head>
</html>
prac1.js
var str = "Karan Gajjar - Android Developer";
var result = str.link("https://goo.gl/gmzl4t");
document.write(result);
Subscribe to:
Posts (Atom)