Home  >  Article  >  Web Front-end  >  Share some unpopular knowledge about html5

Share some unpopular knowledge about html5

零下一度
零下一度Original
2017-05-10 13:54:142231browse

HTML is the unified language of the Web. These rough tags contained in angle brackets constitute today's Web. In 1991, Tim Berners-Lee wrote a document called "HTML Tags", which includes about 20 HTML tags used to mark web pages. He directly borrowed the markup style of SGML, which is the HTML markup style we saw later.

Today, the editor of Huwu will sort out the html5 cold knowledge that you may not know.

Run the browser address barJavaScriptCode
Many people should still know this. You can run JavaScript code directly in the browser address bar. The method is to start with javascript: followed by execution statement. For example:

Share some unpopular knowledge about html5

## Note that to execute the javascript code, you need to enter it manually in the browser. If you copy the code, IE and

Chr Ome will automatically remove the javascript: at the beginning of the code, so it needs to be added manually for correct execution. Although Firefox will not automatically remove it, it does not support running JS code in the address bar at all! !

Run HTML code in the browser address bar

If more people know the little secret above, fewer people know this tip. In non-IE core browsers The address bar can run HTML code directly!

Anyway, I, the editor of Huwu, only learned about it accidentally recently.

For example, enter the following code in the address bar and press Enter to run. The specified page content will appear.


Share some unpopular knowledge about html5

As shown below:


Share some unpopular knowledge about html5

Treat the browser as

Editor Still making a fuss on the browser address bar, paste the following code into the address bar and run it, and the browser will become a primitive and simple editor, just like the notepad that comes with Windows, roar Roar.

Share some unpopular knowledge about html5

As shown below:


Share some unpopular knowledge about html5

In the final analysis, thanks to HTML5 The newly added contenteditable

attribute, when the element is specified with this attribute, the content of the element becomes editablestate.

By extension, after putting the following code into the console and executing it, the entire page will become editable!


Share some unpopular knowledge about html5

As shown below:


Share some unpopular knowledge about html5
##Use a tag to automatically parse URL

Many times we have the need to extract domain names from a URL,

query
keywords,variablesparameter values, etc., but we never expected that the browser can easily help We accomplish this task without writing regular code to capture it. The method is to first create an a tag in the JS code and then assign the URL that needs to be parsed to the href attribute of a, and then we get everything we want.

Share some unpopular knowledge about html5
As shown below:


Share some unpopular knowledge about html5
Use the above method to Browser parameters to operate!


Share some unpopular knowledge about html5

Elements with IDs on the page will create global variables
In an HTML page, all elements with ID attributes set will create corresponding global variables in the JavaScript execution environment, which means document.getElementById is as redundant as the human appendix. But in actual projects, it’s best to just write it honestly. After all, the chance of things going wrong with regular code is much smaller.

Share some unpopular knowledge about html5

As shown below:

Share some unpopular knowledge about html5

When loading the CDN file, You can omit the HTTP identifier
Nowadays, the popular CDN loads some common JS and CSS files from a dedicated server. For security considerations, some CDN servers use HTTPS to connect, while others use traditional HTTP, in fact, we can ignore this when using it and omit it from the URL.

Share some unpopular knowledge about html5

Use the script tag to save any information
Set the script tag to type='text' and then you can save any information in it, and then you can Easily available in JavaScript code.

Share some unpopular knowledge about html5

Of course, there are far more trivia than these.

【Related recommendations】

1. Free h5 online video tutorial

2. HTML5 full version manual

3. php.cn original html5 video tutorial

The above is the detailed content of Share some unpopular knowledge about html5. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn