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

Detailed explanation of for loop and double for loop in JavaScript

for loop The for loop loops through the elements ...

FastDFS and Nginx integration to achieve code analysis

FastDFS & Nginx Integration: The tracker is c...

Implementation of a simple login page for WeChat applet (with source code)

Table of contents 1. Picture above 2. User does n...

17 excellent web designs carefully crafted by startups

Startups often bring us surprises with their unco...

Webpack loads css files and its configuration method

webpack loads css files and its configuration Aft...

CentOS 7 Forgot Password Solution Process Diagram

need Whether it is a Windows system or a Linux sy...

How to add fields and comments to a table in sql

1. Add fields: alter table table name ADD field n...

Detailed explanation of HTML onfocus gain focus and onblur lose focus events

HTML onfocus Event Attributes Definition and Usag...

JavaScript data transmission between different pages (URL parameter acquisition)

On web pages, we often encounter this situation: ...

How to configure SSL for koa2 service

I. Introduction 1: SSL Certificate My domain name...

How to use vue-video-player to achieve live broadcast

Table of contents 1. Install vue-video-player 2. ...