Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the unpopular knowledge of html5?

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article will explain in detail what little knowledge about html5 is unpopular, and the editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

HTML is the same language as Web, and these rough tags contained in angle brackets make up the Web today. In 1991, Tim Berners-Lee wrote a document called "HTML tags", which included about 20 HTML tags used to tag web pages. He borrowed the marked style directly from SGML, that is, the HTML marked style that we saw later.

The browser address bar runs the JavaScript code

As many people should know, you can run JavaScript code directly in the browser address bar by starting with _ javascript: followed by the statement to be executed. For example:

Note that to execute the javascript code, to manually enter the code in the browser, if you copy the code, IE and Chrome will automatically remove the _ javascript:, at the beginning of the code, so you need to add it manually to execute it correctly, while Firefox will not automatically remove it, but it does not support running JS code in the address bar at all!

The browser address bar runs the HTML code

If there are many people who know the little secret above, fewer people know it. You can run HTML code directly in the browser address bar of the non-IE kernel.

Anyway, it was only recently that I inadvertently learned about it.

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

As shown below:

Use the browser as an editor

Or do something on the browser address bar, paste the following code to the address bar and run the browser into a primitive and simple editor, just like the notepad that comes with Windows.

As shown below:

In the final analysis, thanks to the new contenteditable attribute in HTML5, when the element specifies this attribute, the content of the element becomes editable.

By extension, after the following code is put into console execution, the entire page will become editable!

As shown below:

Using a tag to automatically parse URL

Many times we have the need to extract domain names, query keywords, variable parameter values, etc., from a URL, but we never thought that it would be convenient for the browser to help us accomplish this task without having to write rules to grab it. The method first creates an a tag in the JS code, then assigns the URL that needs to be parsed to the href attribute of a, and then gets everything we want.

As shown below:

Use the above method to manipulate the browser parameters!

The element of the page with ID creates a global variable

In a HTML page, all elements that have the ID attribute set create corresponding global variables in the execution environment of the JavaScript, which means that the document.getElementById is as redundant as a human appendix. But in the actual project, it is best to write honestly what should be written, after all, the regular code is much less likely to go wrong.

As shown below:

When loading CDN files, you can omit the HTTP identity

CDN, which is very popular now, loads some general JS and CSS files from special servers. For security reasons, some CDN servers connect with HTTPS, while others use traditional HTTP. In fact, we can ignore this and omit it from URL.

Use script tags to save arbitrary information

Set the script tag to type='text' and then save any information in it, which can be easily obtained in the JavaScript code.

Of course, cold knowledge is much more than that.

This is the end of this article on "what is the unpopular knowledge of html5?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report