{
"etuNimi": "Matti",
"sukuNimi": "Virtanen",
"osoite": {
"postiToimiNro": 000100,
"postiToimiPaikka": "Helsinki",
"katuOsoite": "Lahnakuja 3 B 7"
},
"puhelinNumerot": [
"09-1234567",
"040-1234567"
]
}
lisää JSONista, suomeksi
Näytetään tekstit, joissa on tunniste javascript. Näytä kaikki tekstit
Näytetään tekstit, joissa on tunniste javascript. Näytä kaikki tekstit
sunnuntai 13. tammikuuta 2008
JSON example
perjantai 12. lokakuuta 2007
What is my current URL?
<script language="Javascript">
function x(){
var a;
a=window.location.href;
a=a.replace('file:///','');
//document.getElementById('MyLoc').innerHTML=a;
//document.write(a);
}
</script>
<!-- if used innerHTML
<body onload="x();">
<span id="MyLoc">!!!</span>
else
<body>
-->
function x(){
var a;
a=window.location.href;
a=a.replace('file:///','');
//document.getElementById('MyLoc').innerHTML=a;
//document.write(a);
}
</script>
<!-- if used innerHTML
<body onload="x();">
<span id="MyLoc">!!!</span>
else
<body>
-->
keskiviikko 12. syyskuuta 2007
Loop through HTML tags and change theirs attributes with Javascript
Idea behind this is to get all images of current webpage and change the picture shown with Javascript.
<html>
<head>
<title>Looping through IMG-tags example</title>
<script type="text/javascript">
function getImages()
{
var images = document.getElementsByTagName("IMG");
var numOfImages = images.length;
var origImage;
for(i=0;i<numOfImages;i++)
{
origImage = images[i].src;
images[i].src="http://www.google.com/ig/images/igoogle_logo_sm.gif";
images[i].alt="Original image used is " + origImage;
}
}
window.onload = getImages;
</script>
</head>
<body>
<img src="http://www.lo.fi/goo.gif" height="55" width="166">
<img src="http://www.lo.fi/gaa.gif" height="55" width="166">
</body>
</html>
<html>
<head>
<title>Looping through IMG-tags example</title>
<script type="text/javascript">
function getImages()
{
var images = document.getElementsByTagName("IMG");
var numOfImages = images.length;
var origImage;
for(i=0;i<numOfImages;i++)
{
origImage = images[i].src;
images[i].src="http://www.google.com/ig/images/igoogle_logo_sm.gif";
images[i].alt="Original image used is " + origImage;
}
}
window.onload = getImages;
</script>
</head>
<body>
<img src="http://www.lo.fi/goo.gif" height="55" width="166">
<img src="http://www.lo.fi/gaa.gif" height="55" width="166">
</body>
</html>
tiistai 4. syyskuuta 2007
Basic Confirm box with Javascript
// Basic Confirm box with Javascript
if (confirm("Do you want to continue?")) {
alert("Yes, you do!");
}
else {
alert("Nah, you don't..");
}
Paste this to external.js -file and call it from HTML page like this
<head>
<script language="javascript" type="text/javascript" src="external.js">
</script>
</head>
language="javascript" is not recommended anymore by W3C. Use only type="text/javascript".
if (confirm("Do you want to continue?")) {
alert("Yes, you do!");
}
else {
alert("Nah, you don't..");
}
Paste this to external.js -file and call it from HTML page like this
<head>
<script language="javascript" type="text/javascript" src="external.js">
</script>
</head>
language="javascript" is not recommended anymore by W3C. Use only type="text/javascript".
Tilaa:
Blogitekstit (Atom)