Tuesday, 1 May 2018

LOAD FUNCTION CHANGE INTO FUNCTION IN JAVA SCRIPT

LOAD FUNCTION CHANGE INTO FUNCTION


-----------------------------------------------------------------------------------------------------------------
LOAD FUNCTION CHANGE INTO FUNCTION 
-----------------------------------------------------------------------------------------------------------------
<html>
<head>
<script type='text/javascript'>
window.onload = function() {
x = "https://www.w3schools.com/js/SMILEY.gif",
document.getElementById("myImg").src= x;
}
</script>
</head>
<body>
<img  id="myImg">
</body>
</html>
//OR USE THIS CODE
<html>
<head>
<script type='text/javascript'>
function myFunction(){
x = "https://www.w3schools.com/js/SMILEY.gif",
document.getElementById("myImg").src= x;
}
</script>
</head>
<body onLoad = "myFunction()">
<img  id="myImg">
</body>
</html>
-----------------------------------------------------------------------------------------------------------------
WINDOW LOAD FUNCTION  CHANGE INTO FUNCTION
 WINDOW LOAD FUNCTION= JAVASCRIPT+HTML CODE
FUNCTION= HTML CODE + JAVASCRIPT
-------------------------------------------------------------------------------------------------------------------
<script type='text/javascript'>
window.onload = function(){
x = "https://www.w3schools.com/js/SMILEY.gif",
document.getElementById("myImg").src= x;
}
myFunction();
</script>
<p id="myFunction()"></p>
<img  id="myImg">
================================================================
<p id="myFunction()"></p>
<img  id="myImg">
<script>
function myFunction() {
x = "https://www.w3schools.com/js/SMILEY.gif",
document.getElementById("myImg").src= x;
}
myFunction();
</script>
--------------------------------------------------------------------------------------------------------------------
FUNCTION RUN WITH BUTTON 
BODY TAG CODE CHANGE INTO BUTTON
<body onLoad = "myFunction()">
<button type="button" onclick="myFunction()">Try it</button>
------------------------------------------------------------------------------------------------------------------
<html>
<head>
<script type='text/javascript'>
function myFunction(){
x = "https://www.w3schools.com/js/SMILEY.gif",
document.getElementById("myImg").src= x;
}
</script>
</head>
<button type="button" onclick="myFunction()">Try it</button>
<img  id="myImg">
</html>
------------------------------------------------------------------------------------------------------------------
FUNCTION USE IMAGE
------------------------------------------------------------------------------------------------------------------
<html>
<body>
<p id="myFunction()"></p>
<img  id="myImg">
<script>
function myFunction() {
x = "https://www.w3schools.com/js/SMILEY.gif",
document.getElementById("myImg").src= x;
}
myFunction();
</script>
</body>
</html>
--------------------------------------------------------------------------------------------------------------------

0 comments:

Post a Comment

FB Gadgets | Template Designed by Fatakat PhotosCoolBThemes.com
Code by : paid web directory

https://www.google.co.uk/search?q=site%3Ablogspot.com+fbgadgets