To demonstrate string and math object’s predefined methods using javascript.
Example of String!!
Source Code:
<!DOCTYPE html>
<html>
<head>
<title>JS7</title>
</head>
<body>
<p id="p1">Please locate where 'locate' occurs!.</p>
<button onclick="stringindex()">Try it</button>
<p id="pos"></p>
<p id="lastpos"></p>
<hr>
<a href="E:\documents\IM LAB\html\html3-mail link.html">Sanjampreet Singh</a>
<br>
<a href="http://sanjamhelping.blogspot.in/p/it-14304-it-methodologies-lab.html">Department Of Information Technology</a>
<br>
<a href="E:\documents\IM LAB\html\js6\js6.html"><-Last Practical</a>
<a href="E:\documents\IM LAB\html\js7\js7_1.html">Next Practical-></a>
<br>
<script>
function stringindex()
{
var str = document.getElementById("p1").innerHTML;
var pos = str.indexOf("locate");
var last_pos = str.lastIndexOf("locate");
document.getElementById("pos").innerHTML = "Word locate occurs at "+pos;
document.getElementById("lastpos").innerHTML = "Word locate occurs last at "+last_pos;
}
</script>
</body>
</html>
Output:
Include the following source Code in Document Environment in your LaTeX File
LaTeX Source:
\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{multicol}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{transparent}
\usepackage{multirow}
\usepackage{eso-pic}
\usepackage[utf8]{inputenc}
\usepackage{color}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\BackgroundIm{
\put(0,0){
\parbox[b][\paperheight]{\paperwidth}{
\vfill
\centering
{\transparent{0.05} \includegraphics[height=\paperheight,width=\paperwidth,
keepaspectratio]{gne}
\vfill
}}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\AddToShipoutPicture{\BackgroundIm}
\newpage
\section{\emph{To demonstrate string and math object’s predefined methods using javascript.}}
\subsection{\emph{Source Code:}}
\begin{verbatim}
<!DOCTYPE html>
<html>
<head><title>JS7</title></head>
<body>
<p id="p1">Please locate where 'locate' occurs!.</p>
<button onclick="stringindex()">Try it</button>
<p id="pos"></p><p id="lastpos"></p><hr>
<a href="E:\documents\IM LAB\html\html3-
mail link.html">Sanjampreet Singh</a><br>
<a href="http://sanjamhelping.blogspot.in/p/it-14304-it-method
ologies-lab.html">Department Of Information Technology</a><br>
<a href="E:\documents\IM LAB\html\js6\js6.html"><-Last Practical</a>
<a href="E:\documents\IM LAB\html\js7\js7_1.html">Next Practical-></a><br>
<script>function stringindex()
{var str = document.getElementById("p1").innerHTML;
var pos = str.indexOf("locate");var last_pos = str.lastIndexOf("locate");
document.getElementById("pos").innerHTML = "Word locate occurs at "+pos;
document.getElementById("lastpos").innerHTML = "Word locate occurs last at "+last_pos;}
</script></body>
</html>
\end{verbatim}
\subsubsection{\emph{Output:}}
\begin{figure}[h]
\centering
\includegraphics[scale=0.5]{js7}
\caption{Output Of HTML page with Js}
\end{figure}
\end{document}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{multicol}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{transparent}
\usepackage{multirow}
\usepackage{eso-pic}
\usepackage[utf8]{inputenc}
\usepackage{color}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\BackgroundIm{
\put(0,0){
\parbox[b][\paperheight]{\paperwidth}{
\vfill
\centering
{\transparent{0.05} \includegraphics[height=\paperheight,width=\paperwidth,
keepaspectratio]{gne}
\vfill
}}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\AddToShipoutPicture{\BackgroundIm}
\newpage
\section{\emph{To demonstrate string and math object’s predefined methods using javascript.}}
\subsection{\emph{Source Code:}}
\begin{verbatim}
<!DOCTYPE html>
<html>
<head><title>JS7</title></head>
<body>
<p id="p1">Please locate where 'locate' occurs!.</p>
<button onclick="stringindex()">Try it</button>
<p id="pos"></p><p id="lastpos"></p><hr>
<a href="E:\documents\IM LAB\html\html3-
mail link.html">Sanjampreet Singh</a><br>
<a href="http://sanjamhelping.blogspot.in/p/it-14304-it-method
ologies-lab.html">Department Of Information Technology</a><br>
<a href="E:\documents\IM LAB\html\js6\js6.html"><-Last Practical</a>
<a href="E:\documents\IM LAB\html\js7\js7_1.html">Next Practical-></a><br>
<script>function stringindex()
{var str = document.getElementById("p1").innerHTML;
var pos = str.indexOf("locate");var last_pos = str.lastIndexOf("locate");
document.getElementById("pos").innerHTML = "Word locate occurs at "+pos;
document.getElementById("lastpos").innerHTML = "Word locate occurs last at "+last_pos;}
</script></body>
</html>
\end{verbatim}
\subsubsection{\emph{Output:}}
\begin{figure}[h]
\centering
\includegraphics[scale=0.5]{js7}
\caption{Output Of HTML page with Js}
\end{figure}
\end{document}
\subsubsection{\emph{Output:}}
\begin{figure}[h]
\centering
\includegraphics[scale=0.5]{js7}
\caption{Output Of HTML page with Js}
\end{figure}
\end{document}
Output:
Math Objects
Source Code:
<!DOCTYPE html>
<html>
<head>
<title>JS7</title>
</head>
<body>
<p>Math.random() returns a random number between 0 and 1. Every time Output varies between 0 and 1</p><p id="random_no"></p>
<p>Math.min() returns the lowest value.</p>
<p id="min"></p>
<p>Math.round() rounds a number to its nearest integer.</p>
<p>Math.ceil() rounds a number <strong>up</strong> to its nearest integer.</p>
<p id="round"></p>
<p>Math constants are E, PI, SQR2, LN2, LN10, LOG2E, LOG10E</p>
<p id="const"></p>
<hr>
<a href="E:\documents\IM LAB\html\html3-mail link.html">Sanjampreet Singh</a>
<br>
<a href="http://sanjamhelping.blogspot.in/p/it-14304-it-methodologies-lab.html">Department Of Information Technology</a>
<br>
<a href="E:\documents\IM LAB\html\js7\js7.html"><-Last Practical</a>
<a href="E:\documents\IM LAB\html\js8\js8.html">Next Practical-></a>
<br><script>
document.getElementById("random_no").innerHTML = "<b>Output of Math.Random() is</b>"+Math.random();
document.getElementById("min").innerHTML = "<b>Math.Min(0, 150, 30, 20, -8, -200) returns min value from set of parameters passed</b> "+ Math.min(0, 150, 30, 20, -8, -200);
document.getElementById("round").innerHTML = "<b>Math.Round(4.4) and Math.ceil(4.4) round off the value to nearest integer</b> "+Math.round(4.4) +" and " + Math.ceil(4.4);
document.getElementById("const").innerHTML = "<b>Value of E using Math.E</b> "+Math.E + "<br>" + "<b>Value of PI using Math.PI</b> "+Math.PI + "<br>" + "<b>Value of SQRT2 using Math.SQRT2</b> "+Math.SQRT2 + "<br>" + "<b>Value of LN2 using Math.LN2</b> "+Math.LN2 + "<br>" + "<b>Value of LN10 using Math.LN10</b> "+Math.LN10 + "<br>" + "<b>Value of LOG2E using Math.LOG2E</b> "+Math.LOG2E + "<br>" + "<b>Value of LOG10E using Math.LOG10E</b> "+Math.LOG10E + "<br>";
</script>
</body>
</html>
Output:
Include the following source Code in Document Environment in your LaTeX File
LaTeX Source:
\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{multicol}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{transparent}
\usepackage{multirow}
\usepackage{eso-pic}
\usepackage[utf8]{inputenc}
\usepackage{color}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\BackgroundIm{
\put(0,0){
\parbox[b][\paperheight]{\paperwidth}{
\vfill
\centering
{\transparent{0.05} \includegraphics[height=\paperheight,width=\paperwidth,
keepaspectratio]{gne}
\vfill
}}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\AddToShipoutPicture{\BackgroundIm}
\newpage
\section{\emph{To demonstrate string and math object’s predefined methods using javascript.}}
\subsection{\emph{Source Code:}}
\begin{verbatim}
<html>
<head><title>JS7</title></head>
<body>
<p>Math.random() returns a random number between 0 and 1.
Every time Output varies between 0 and 1</p><p id="random_no"></p>
<p>Math.min() returns the lowest value.</p><p id="min"></p>
<p>Math.round() rounds a number to its nearest integer.</p>
<p>Math.ceil() rounds a number<strong>up</strong> to its nearest integer.</p>
<p id="round"></p><p>Math constants are E,PI,SQR2,LN2LN10,LOG2E,LOG10E</p>
<p id="const"></p><a href="E:\documents\html3-maillink.html">SanjampreetSingh</a>
<a href="http://sanjamhelping.blogspot.in/p/it-14304-it-
methodologies-lab.html">Department Of Information Technology</a><br>
<a href="E:\documents\IM LAB\html\js7\js7.html"><-Last Practical</a>
<a href="E:\documents\IM LAB\html\js8\js8.html">Next Practical-></a>
<script>document.getElementById("random_no").innerHTML =
"Output of Math.Random()"+Math.random();document.getElementById("min").innerHTML
="Math.Min(0,150,30,20,-8,-200) returns min value from set of parameters passed"+
Math.min(0, 150, 30, 20, -8, -200);document.getElementById("round").innerHTML=
"Math.Round(4.4) and Math.ceil(4.4) round off the value to nearest integer''+
Math.round(4.4)+"and''+Math.ceil(4.4);document.getElementById("const").innerHTML=
"<b>Value of E using Math.E</b>"+Math.E +''Value of PI using Math.PI</b>"
+Math.PI+"Value of SQRT2 using Math.SQRT2"+Math.SQRT2+
"Value of LN2 using Math.LN2"+Math.LN2 <b>Value of LN10 using Math.LN10"
+Math.LN10 +"<br>"+"<b>Value of LOG2E using Math.LOG2E</b>"+Math.LOG2E"+
"<b>Value of LOG10E using Math.LOG10E</b> "+Math.LOG10E +"<br>";</script>
</body>
</html>
\end{verbatim}
\newpage
\subsubsection{\emph{Output:}}
\begin{figure}[h]
\centering
\includegraphics[scale=0.8]{js7_1}
\caption{Output Of HTML page with Js}
\end{figure}
\end{document}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{multicol}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{transparent}
\usepackage{multirow}
\usepackage{eso-pic}
\usepackage[utf8]{inputenc}
\usepackage{color}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\BackgroundIm{
\put(0,0){
\parbox[b][\paperheight]{\paperwidth}{
\vfill
\centering
{\transparent{0.05} \includegraphics[height=\paperheight,width=\paperwidth,
keepaspectratio]{gne}
\vfill
}}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\AddToShipoutPicture{\BackgroundIm}
\newpage
\section{\emph{To demonstrate string and math object’s predefined methods using javascript.}}
\subsection{\emph{Source Code:}}
\begin{verbatim}
<html>
<head><title>JS7</title></head>
<body>
<p>Math.random() returns a random number between 0 and 1.
Every time Output varies between 0 and 1</p><p id="random_no"></p>
<p>Math.min() returns the lowest value.</p><p id="min"></p>
<p>Math.round() rounds a number to its nearest integer.</p>
<p>Math.ceil() rounds a number<strong>up</strong> to its nearest integer.</p>
<p id="round"></p><p>Math constants are E,PI,SQR2,LN2LN10,LOG2E,LOG10E</p>
<p id="const"></p><a href="E:\documents\html3-maillink.html">SanjampreetSingh</a>
<a href="http://sanjamhelping.blogspot.in/p/it-14304-it-
methodologies-lab.html">Department Of Information Technology</a><br>
<a href="E:\documents\IM LAB\html\js7\js7.html"><-Last Practical</a>
<a href="E:\documents\IM LAB\html\js8\js8.html">Next Practical-></a>
<script>document.getElementById("random_no").innerHTML =
"Output of Math.Random()"+Math.random();document.getElementById("min").innerHTML
="Math.Min(0,150,30,20,-8,-200) returns min value from set of parameters passed"+
Math.min(0, 150, 30, 20, -8, -200);document.getElementById("round").innerHTML=
"Math.Round(4.4) and Math.ceil(4.4) round off the value to nearest integer''+
Math.round(4.4)+"and''+Math.ceil(4.4);document.getElementById("const").innerHTML=
"<b>Value of E using Math.E</b>"+Math.E +''Value of PI using Math.PI</b>"
+Math.PI+"Value of SQRT2 using Math.SQRT2"+Math.SQRT2+
"Value of LN2 using Math.LN2"+Math.LN2 <b>Value of LN10 using Math.LN10"
+Math.LN10 +"<br>"+"<b>Value of LOG2E using Math.LOG2E</b>"+Math.LOG2E"+
"<b>Value of LOG10E using Math.LOG10E</b> "+Math.LOG10E +"<br>";</script>
</body>
</html>
\end{verbatim}
\newpage
\subsubsection{\emph{Output:}}
\begin{figure}[h]
\centering
\includegraphics[scale=0.8]{js7_1}
\caption{Output Of HTML page with Js}
\end{figure}
\end{document}
Comments
Post a Comment