HTML Scripts

Links to HTML projects source code & tutorials
Site Admin
Posts: 159
Joined: Sun Jun 26, 2022 10:46 pm

HTML Scripts

Post by C0D3D »

Insert JavaScript inside the HTML pages to add interactivity - The script element

Example 1

Code: Select all

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Embedding JavaScript</title>
</head>
<body>
    <div id="greet"></div>
    <script>
        document.getElementById("greet").innerHTML = "Hello World!";
    </script>
</body>
</html>
Include external JavaScript file inside the HTML pages

Example 2

Code: Select all

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>External JavaScript Example</title>        
</head>
<body>
    <script type="text/javascript" src="/hello.js"></script>
</body>
</html>
Provide alternative content if script isn't supported or disabled - The noscript element

Example 3

Code: Select all

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>No-script Example</title>        
</head>
<body>
    <script type="text/javascript">
        document.write("Hello World!");
    </script>
    <noscript>
        <p>Sorry, your browser does not support JavaScript!</p>
    </noscript>
</body>
</html>
----------------------------------------------------------------------
Together we are one! One we are many... Much Love from one brother to another...
Working together to achieve amazing things!
Teamwork is key.
Knowledge is Power!

4 Basic datatypes.
Strings: Which store a series of characters.
Int: Which store a full integer or number.
Float: A numeric value with a decimal.
Boolean: Only stores True or False and are very useful with if statements

----------------------------------------------------------------------
ImgBB Image upload

Who is online

Users browsing this forum: No registered users and 0 guests