Thursday, July 20, 2023

PAGE REDIRECT and Browser Detection

 

PAGE REDIRECT

If you clicked a URL to reach a page

JavaScript Page Refresh

 <a href="javascript:location.reload(true)">Refresh Page</a>

 

Auto Refresh

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Document</title>

 

    <h2 style="background-color: rgb(9, 238, 9);color:rgb(255, 0, 0);font-weight: bolder;font-family: Georgia, 'Times New Roman', Times, serif;">Page Redirect</h2>

    <h5 style="color: rgb(231, 15, 166);">Output</h5>

    <script type="text/javascript">

   function AutoRefresh( t ) {

setTimeout("location.reload(true);", t);

   }

 

        </script>

</head>

<body onload="JavaScript:AutoRefresh(3000);">

    <a href="javascript:location.reload(true)">Refresh Page</a>

    <p>This page will refresh every 3 seconds.</p>

 

</body>

</html>

 

Redirect to new page

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Document</title>

    <h3 style="color: yellow;font-weight:bolder;background-color: blue;">Page Redirect Output</h3>

</head>

<body>

    <p style="color: green;font-size:x-large;background-color:blanchedalmond;">Lorem ipsum dolor sit amet consectetur adipisicing elit. Accusantium illum magnam rerum nostrum molestias accusamus numquam, saepe nam minima repudiandae vel perspiciatis? Eveniet eum tempore voluptate veritatis illum distinctio cumque!</p>

</body>

</html>

 

Output





DIALOG BOX

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Document</title>

 

    <h2 style="background-color: rgb(9, 238, 9);color:rgb(255, 0, 0);font-weight: bolder;font-family: Georgia, 'Times New Roman', Times, serif;">Dialog box</h2>

    <h5 style="color: rgb(231, 15, 166);">Output</h5>

    <script type="text/javascript">

  function getValue(){

 var retVal = prompt("Enter your name : ", "your name here");

 

 document.write("You have entered : " + retVal);

}

     </script>

</head>

<body>

    <p>Click to see the result: </p>

    <form>

    <input type="button" value="Click Me" onclick="getValue();" />

    </form>

</body>

</html>

 

Output





















JavaScript Browser Detection

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Document</title>

 

    <h2 style="background-color: rgb(9, 238, 9);color:rgb(255, 0, 0);font-weight: bolder;font-family: Georgia, 'Times New Roman', Times, serif;">Dialog box</h2>

    <h5 style="color: rgb(231, 15, 166);">Output</h5>

   

</head>

<body>

    <script type="text/javascript">

        document.write("Browser CodeName: " + navigator.appCodeName);

        document.write("<br /><br />");

        document.write("Browser Name: " + navigator.appName);

        document.write("<br /><br />");

        document.write("Browser Version: " + navigator.appVersion);

        document.write("<br /><br />");

        document.write("Cookies Enabled: " + navigator.cookieEnabled);

        document.write("<br /><br />");

        document.write("Platform: " + navigator.platform);

        document.write("<br /><br />");

        document.write("User-agent header: " + navigator.userAgent);

        </script>

       

</body>

</html>

 

Output



0 comments:

Post a Comment