Web Dev Series 4 - How to add a favicon, onclick event and JS functions etc.

Web Dev Series 4 - How to add a favicon, onclick event and JS functions.








onclick: This is a JavaScript event through which we can add a function while clicking on the button. For example if you want to add a alert as same as shown in the above you have to first create a button and then an alert and then you have to add some effects in the button give onclick and function.


Like onclick="myfunction()" and then you have to create a variable in it after giving writting the function in the script tag and then you have to do DOM manipulation (DOM Manipulation means you have to select the id or the class so that you can give styling, injecting HTML in it etc) and then you have to give the variable name.style (you have to use .style if you want to inject CSS in JavaScript) and at last you have give the CSS property like this = top = '0%'.


functions: Functions is to give or add some functionality in the element to use function you have to first give the function name as shown in the image and then you can add the script src or you can write that in the [inline JavaScript - (<script>//Here You Can Write The JavaScript In The Page</script>)] and in script you have to give that it's a function and at then it's name. For Ex - function myfunction(){
//And Here You Can Write Your JavaScript
}


transition: This is to add a fast or a slow effect in the element like button or etc.


Inline-JavaScript: This helps you to write the JavaScript in the page it's like in CSS you use internal CSS then it's similar to that only but JS means it to be inline JS to use inline JS you only have to give the script tag in the <html> tag but if you want that your website can load fast then you should add it in the last before the body tag.


External-JavaScript: This is to use JS externally in a different page fir creating a external JS file you have to add .js like - main.js or etc but the extension should be kept as .js and you have to give the source of the JS file in the HTML file to use it externally like - <script src="main.js">.

1. How to add a favicon in website ?

To add favicon in website through HTML you have to give the tag <link> tag and then the file the mention that it's a icon using <link rel="icon" and then it's location and if you want to mention it's type the you can using type="" and if you want to mention it's size also for that you have to write sizes="width and the height like - 10x10"> and the code will look like this <link rel="icon" href="Images/favicon.png"type="image/png"size="10x10">.


Conclusion


We have discussed a lot about JavaScript today and we have covered some basic concepts like JS functions and more many people don't know how to add Favicon. So, for this I have also mentioned how can we do it and if you any suggestions regarding our articles and our blogs then don't forget to share it with us.

Post a Comment

0 Comments