0% found this document useful (0 votes)
642 views9 pages

Css Practical 10 & 11

The document contains code from several JavaScript practical experiments conducted by 21482 Ashish KHOBRAGADE. It includes code to set and read cookies, open child windows and pass data between them, get a user's location, manipulate window size and scrolling, and use the browser history functions. The code samples demonstrate various JavaScript DOM and window methods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
642 views9 pages

Css Practical 10 & 11

The document contains code from several JavaScript practical experiments conducted by 21482 Ashish KHOBRAGADE. It includes code to set and read cookies, open child windows and pass data between them, get a user's location, manipulate window size and scrolling, and use the browser history functions. The code samples demonstrate various JavaScript DOM and window methods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

21482 ASHISH KHOBRAGADE

PRACTICAL NO.: 10
CODE:

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Experiment 10_1</title>

<script>

function WriteCookie(){

var now = new Date();

now.setMonth(now.getMonth() +1);

cookievalue = escape(document.myform.customer.value)+ ";";

document.cookie = "name=" + cookievalue;

document.cookie = "expires=" + now.toUTCString() + ";";

cookievalue = document.cookie;

document.write("Setting Cookies : " +cookievalue);

</script>

</head>

<body>

<h4>21482 Ashish KHOBRAGADE </h4>

<form name="myform" action="">

Enter Name: <input type="text" name="customer"/>

<input type="button" value="Set Cookie" onclick="WriteCookie()">

</form>

</body>

</html>

OUTPUT :
21482 ASHISH KHOBRAGADE

CODE:

<html>

<head>

<title>Experiment No.10</title>

<script>

function WriteCookie() {

cookievalue = escape(document.Form.c_name.value) + ";";

document.cookie = "First Name=" + cookievalue;

cookievalue = escape(document.Form.c_l.value) + ";";

document.cookie = "Last Name=" + cookievalue;

cookievalue = escape(document.Form.c_age.value) + ";";

document.cookie = "Age= " + cookievalue;

document.cookie = "Username=" + cookievalue;

cookievalue = escape(document.Form.c_p.value) + ";";

document.cookie = "Password=" + cookievalue;

let a="Session cookies of your details created.";

let b=a.toUpperCase();

document.write(b);

document.write("<hr>");

var allcook = document.cookie;

var val = [5];

val = allcook.split(";");

for (i = 0; i < 5; i++) {

txt = val[i];

document.write( txt );

</script>

</head>

<body>

<form name="Form">

<center>ENTER DETAILS</center>

<div>

<hr>

First Name:<input type="text" name="c_name" /><br><br>

Last Name:<input type="text" name="c_l" /><br><br>

Age:<input type="text" name="c_age" /><br><br>

Username:<input type="text" name="c_u" /><br><br>

Password:<input type="password" name="c_p" /><br><br><br>

<input type="button" class="bttn" value="Submit" onclick="WriteCookie()">

</div>

</form>

</body>

</html>

OUTPUT:
21482 ASHISH KHOBRAGADE
21482 ASHISH KHOBRAGADE

PRACTICAL NO.: 11
CODE:

<!DOCTYPE html>

<html>

<head>

<title>

21482 ASHISH KHOBRAGADE

</title>

</head>

<body>

21482 ASHISH KHOBRAGADE <hr>

<input type="button" onclick="child()" value="Open Child Window">

<script>

function child(){

var newWindow = window.open("child.html","_blank")

newWindow.focus()

</script>

</body>

</html>

OUTPUT :
21482 ASHISH KHOBRAGADE

CODE:

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>21482 ASHISH KHOBRAGADE</title>

</head>

<body>

21482 ASHISH KHOBRAGADE <hr>

<label>ENTER YOUR TEXT HERE:</label>

<input type="text" id="txt1" value=""> <hr>

<input type="button" id="btn1" value="Open" onclick="OpenElement()">

<input type="button" id="btn2" value="Send" onclick="SendElement()">

<script>

var popchild;

function OpenElement(){

popchild= window.open("child.html","_blank")

function SendElement(){

if (popchild!=null && !popchild.closed) {

var p = popchild.document.getElementById("p1");

p.innerHTML=document.getElementById("txt1").value;

popchild.focus()

else{

alert("Child window has been closed.");

</script>

</body>

</html>

OUTPUT :
21482 ASHISH KHOBRAGADE

CODE:

<!DOCTYPE html>

<html lang="en">

<head>

<title>21482 ASHISH KHOBRAGADE</title>

</head>

<body>

<h4>21482 ASHISH KHOBRAGADE</h4><hr>

<input type="button" id="btn1" value="Try" onclick="getLocation()" />

</body>

<script>

function getLocation() {

if (navigator.geolocation) {

navigator.geolocation.getCurrentPosition(showPosition);

else {

alert("GeoLocation is not supported by this browser");

function showPosition(position) {

document.write("Latitude:" + position.coords.latitude + "<br>Longitude:" +


position.coords.longitude);

</script>

</html>

OUTPUT:
21482 ASHISH KHOBRAGADE

CODE:
<!DOCTYPE html>

<html>

<head>

<title>21482 ASHISH KHOBRAGADE</title>

<style>

body {

width: 5000px;

height: 7500px;

</style>

</head>

<body>

<h4>21482 ASHISH KHOBRAGADE</h4><hr>

<input type="button" value="SIZE AT" id="btn1" onclick="SizeAtfunction()" />

<input type="button" value="SIZE BY" id="btn2" onclick="SizeByfunction()" /><br>

<input type="button" value="MOVE AT" id="btn3" onclick="MoveAtfunction()" />

<input type="button" value="MOVE BY" id="btn4" onclick="MoveByfunction()" /><br>

<input type="button" id="btn5" value="SCROLL TO" onclick="scrollWin(0,-50)" />

<input type="button" id="btn6" value="SCROLL BY" onclick="scrollWin1(0,50)" /><br>

<input type="button" value="OPEN" id="btn8" onclick="WinOpen()" />

<input type="button" value="CLOSE" id="btn7" onclick="Closefunction()" />

<script>

var newwin1;

function WinOpen() {

newwin1 = window.open("", "Window", "width=500,height=200,scrollbars=1");

newwin1.document.write("This is window" + "<br>");

newwin1.focus();

function SizeAtfunction() {

newwin1.resizeTo(200, 50);

newwin1.document.write("This is window is SizedTo()" + "<br>");

newwin1.focus();

function SizeByfunction() {

newwin1.resizeBy(200, 50);

newwin1.document.write("This is window is SizedBy()" + "<br>");

newwin1.focus();

function Closefunction() {

newwin1.close();

function MoveAtfunction() {

newwin1.moveTo(200, 50);

newwin1.document.write("This is window is MovedTo()" + "<br>");

newwin1.focus();

function MoveByfunction() {

newwin1.moveBy(300, 500);

newwin1.document.write("This is window is MovedBy()" + "<br>");

newwin1.focus();

function scrollWin() {

newwin1.scrollTo(300, 300);

newwin1.document.write("This is window is ScrollTo()" + "<br>");

newwin1.focus();

function scrollWin1() {

newwin1.scrollBy(0, -50);

newwin1.document.write("This is window is ScrollBy()" + "<br>");

21482 ASHISH KHOBRAGADE

newwin1.focus();

</script>

</body>

</html>

OUTPUT:
21482 ASHISH KHOBRAGADE

CODE:
<!DOCTYPE html>

<html>

<head>

<title>Document</title>

<script>

document.write("21482 ASHISH KHOBRAGADE<hr>");

var x = history.length;

document.write("Number of URL in history: "+x);

function goBack() {

window.history.forward();

function goForward() {

window.history.forward();

function goBack() {

window.history.go(-2);

</script>

</head>

<body><br><br>

<button onclick="goBack()">Go Back</button>

<button onclick="goForward()">Go Forward</button>

<button onclick="goBack()">Go 2 pages back</button>

<form name="f1" action="">

<a href="https://www.youtube.com/">

<p id="d1">Locate to Youtube</p>

</a>

</form>

</body>

</html>

OUTPUT:

You might also like