The most basic code for web pages

The most basic code for web pages
◆Add to favorites
illustrate Click to add your website to your browser's favorites menu
Code <span style="CURSOR: hand" onClick="window.external.addFavorite('https://www.jb51.net','123WORDPRESS.COM')" title="123WORDPRESS.COM">Add this site to favorites</span>

◆Set as homepage
illustrate Click to set your website as your browser's start page
Code <span onclick="var strHref=window.location.href;this.style.behavior='url(#default#homepage)';
this.setHomePage('https://www.jb51.net');" style="CURSOR: hand">Set as homepage</span>

◆Remove the underline of the hyperlink
illustrate Sometimes it’s annoying to see the underline on a hyperlink. Put the following code between the <head> and </head> of the web page source code, and the underline will disappear without a trace!
Note that there should be no attributes such as link in the <body> tag of the web page, otherwise this effect will be invalid!
Code <style TYPE="text/css">
<!--
A:link{text-decoration:none}
A:visited{text-decoration:none}
A:hover {color: #ff00ff;text-decoration:underline}
-->
</style>

◆Automatically refresh web pages
illustrate To automatically refresh the web page, add the following code between the and of HTML, and the page you are browsing will automatically change to target.html after 5 minutes. In the code, 300 is the refresh delay time in seconds. targer.html is the target page you want to redirect to. If it is this page, it will automatically refresh this page.
Code <meta http-equiv="refresh" content="300; url=target.html">

◆Refresh this page
illustrate Click to refresh this page.
Code <a href="javascript:location.reload()" target="_self">Refresh</a>

◆Return to the previous page
illustrate Click to return to the previous page.
Code <a href="javascript:history.back(-1)">Return to the previous page</a>

◆ Pop up a small window
illustrate When you open the page with the following code, a small window of 468x60 will pop up. "window.html" is the web page to be displayed in the small window that pops up. Toolbar, status, menubar, scrollbars, set the toolbar, status bar, menu bar and scroll bar of the small window, resizable sets whether the browser can change the size of the small window, width and height set the width and height of the small window. (However, such small windows are generally unwelcome!)
Code <script language="JavaScript">
window.open("window.html","www_helper_net","toolbar=no, status=no,menubar=no, scrollbars=no,resizable=no,width=468,height=60,left=200,top=50");
</script>

◆Automatically close the window
illustrate Add the following code to the web page source code, and the window will automatically close after 20 seconds! This is perfect for use with pop-up windows! In the code, "i=20" means the closing delay time is 20 seconds, which can be modified at will.
Code <script language="javascript">
<!--
function clock(){i=i-1
document.title="This window will automatically close in "+i+" seconds!";
if(i>0)setTimeout("clock();",1000);
else self.close();}
var i=20
clock();
//-->
</script>

◆Add protection to the page
illustrate If you don’t want your hard work to be easily copied and pasted by others, you might as well add the following code to your HTML. When you right-click on a web page, a warning window appears instead of the desired shortcut menu. "\n\n" indicates a line break.
Code <script language="JavaScript">
function helper()
{
if (event.button==2)alert('For browsing only! Thank you!\n\nIf you have any questions, please contact me! ')
}
</script>

Then change <body> to <body onmousedown="helper_net()">

◆Fixed font size
illustrate Have you ever had this experience: a well-designed web page becomes unrecognizable immediately when you set the browser font size to large or small while browsing it? Because the font size has changed, the layout is naturally messed up. Now, just add the following code between the <head> and </head> of the web page source file (it is invalid for text defined by the <font> tag).
Code <style type="text/css">
<!--
body {font-size:9pt}
td {font-size:9pt}
-->
</style>

◆Dynamic welcome message in the status bar
illustrate A welcome message appears in the browser's status bar, running to the left one word at a time!
Code <script language="JavaScript">
<!--
function statusMessageObject(p,d) {
this.msg = MESSAGE
this.out = " "
this.pos = POSITION
this.delay = DELAY
this.i = 0
this.reset = clearMessage
}
function clearMessage() {
this.pos = POSITION
}
var POSITION = 100
var DELAY = 5
var MESSAGE = "Welcome! Welcome to WWW.jb51.net"
var scroll = new statusMessageObject()
function scroller() {
for (scroll.i = 0; scroll.i < scroll.pos; scroll.i++) {
scroll.out += " "
}
if (scroll.pos >= 0)
scroll.out += scroll.msg
else scroll.out = scroll.msg.substring(-scroll.pos,scroll.msg.length)
window.status = scroll.out
scroll.out = " "
scroll.pos--
if (scroll.pos < -(scroll.msg.length)) {
scroll.reset()
}
setTimeout ('scroller()',scroll.delay)
}
function snapIn(jumpSpaces,position) {
var msg = scroll.msg
var out = ""
for (var i=0; i<position; i++)
{out += msg.charAt(i)}
for (i=1;i<jumpSpaces;i++)
{out += " "}
out += msg.charAt(position)
window.status = out
if (jumpSpaces <= 1) {
position++
if (msg.charAt(position) == ' ')
{position++ }
jumpSpaces = 100-position
} else if (jumpSpaces > 3)
{jumpSpaces *= .75}
else
{jumpSpaces--}
if (position != msg.length) {
var cmd = "snapIn(" + jumpSpaces + "," + position + ")";
scrollID = window.setTimeout(cmd,scroll.delay);
} else {
window.status=""
jumpSpaces=0
position=0
cmd = "snapIn(" + jumpSpaces + "," + position + ")";
scrollID = window.setTimeout(cmd,scroll.delay);
return false
}
return true
}
snapIn(100,0);
// -->
</script>

◆Protect your page from being placed in a frame by others
illustrate Some people are so lazy that they put other people's web pages into the frame of their own web pages, and the results of others become their own, and the real address of the web page cannot be seen! To prevent your work from being plagiarized by these people, you can add the following code to the HTML of your web page, so that your web page will always open in the full window.
Code <Script LANGUAGE="JavaScript">
if(self!=top){top.location=self.location;}
</script>

<<:  Teach you to use dozens of lines of js to achieve cool canvas interactive effects

>>:  What you need to know about creating MySQL indexes

Recommend

JavaScript to achieve progress bar effect

This article example shares the specific code of ...

Detailed explanation of importing/exporting MySQL data in Docker container

Preface We all know that the import and export of...

Solve the problem that Navicat cannot connect to MySQL on the Linux server

At the beginning, I felt sad. The screenshots are...

How to install JDK and Mysql on Ubuntu 18.04 Linux system

Platform deployment 1. Install JDK step1. Downloa...

Why node.js is not suitable for large projects

Table of contents Preface 1. Application componen...

Use of Linux relative and absolute paths

01. Overview Absolute paths and relative paths ar...

How does the MySQL database implement the XA specification?

MySQL consistency log What happens to uncommitted...

How to use MySQL covering index and table return

Two major categories of indexes Storage engine us...

A detailed discussion of components in Vue

Table of contents 1. Component Registration 2. Us...

Docker+gitlab+jenkins builds automated deployment from scratch

Table of contents Preface: 1. Install Docker 2. I...

The difference between Display, Visibility, Opacity, rgba and z-index: -1 in CSS

We often need to control the hidden, transparent ...

HTML marquee tag usage examples

This tag is not part of HTML3.2 and only supports ...

JavaScript Advanced Programming: Variables and Scope

Table of contents 1. Original value and reference...