script java

 

Script for web pages

Script for password of web page :

<script>

 

// Get the input element

var passwordInput = document.getElementById("password");

 

// Function to check whether the password is valid

function checkPassword() {

// Get the password from the input

var password = passwordInput.value;

 

// Check if the password is valid

if (password.length < 8) {

alert("Password must be at least 8 characters long!");

}

Script for authentification in web page :

//This script will authenticate a user on a web page.

 

//Declare variables

var username;

var password;

 

//Prompt user for username and password

username = prompt("Please enter your username:");

password = prompt("Please enter your password:");

 

//Check if username and password match

if (username == "admin" && password == "password") {

alert("You have successfully logged in!");

} else {

Script for insert a picture in web site:

<script>

function insertPicture(url) {

var img = document.createElement('img');

img.src = url;

document.body.appendChild(img);

}

 

insertPicture('https://example.com/image.jpg');

</script>

Script for insert link  in web site

<script>

function insertLink() {

var link = prompt("Please enter the URL");

if (link != null) {

document.execCommand("createLink", false, link);

}

}

</script>

Script for insert form text in web site

 

<script>

 

// Get the form element

var form = document.getElementById("myForm");

 

// Get the input elements

var nameInput = document.getElementById("name");

var emailInput = document.getElementById("email");

 

// Add an event listener to the form

form.addEventListener("submit", function(event) {

// Prevent the form from submitting

event.preventDefault();

Script for insert checkbox in web site

<form>

<input type="checkbox" name="vehicle" value="Bike"> I have a bike<br>

<input type="checkbox" name="vehicle" value="Car"> I have a car<br>

<input type="checkbox" name="vehicle" value="Truck"> I have a truck<br>

<input type="submit" value="Submit">

</form>

 

Script for insert head balise in web site

<script>

document.head.insertAdjacentHTML('beforeend', '<meta charset="utf-8">');

</script>

 

Script for insert search in web site

//Create a function to insert a search bar

function insertSearchBar(){

//Create a search bar element

var searchBar = document.createElement("input");

//Set the type of the element to "search"

searchBar.type = "search";

//Set the placeholder text

searchBar.placeholder = "Search...";

//Append the search bar to the page

document.body.appendChild(

 

Commentaires