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

How does Javascript realize Mini Program to say hello to the viewer?

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

Share

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

The main content of this article is to explain "how to achieve Mini Program to greet visitors with Javascript". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "how to achieve Mini Program to say hello to the viewer by Javascript".

I. the greeting program based on the layer

The source code is as follows:

< script language= "Javascript" >

Function textprintdown () / / Custom run function

{

Textmesg=prompt ("Please enter your name, thank you very much!" , ") / / set the user input box

[xss_clean] ('< div id= "Layer1" style= "position:absolute; width:643px; height:115px; z index1; background-color: # FFFFFF; layer-background-color: # FFFFFF; border: 1px none # 000000" >') / / add a layer to the web page

[xss_clean] ('< div align= "center" >') / / sets the format of the layer to center

[xss_clean] ('< font color=9900CC size=5 align=center face= official script >') / / set the text style on the layer to be blue, No. 5, centered, and official script font

[xss_clean] ('< b >') / / sets the text style on the layer to bold

[xss_clean] (textmesg, "Welcome!") / / write the contents of the user box on the layer

[xss_clean] ('< / b >')

[xss_clean] ('< / font >')

[xss_clean] ('< / div >')

[xss_clean] ('< / div >')

}

Textprintdown () / / start running custom function

< / script >

Careful friends who see here will find that this program is not complex, only called JAVAscript two built-in operation functions prompt () and [xss_clean] (). Indeed, this greeting procedure is very simple, but it is important to note that do not set the layer as you like, otherwise the new layer added with JAVAscript will obscure the content on your original page. For this reason, the author suggests that you can first use DREAMWEAVER web page editing software to draw a layer in the blank space of the web page, and then write this layer code into parentheses in [xss_clean] ().

Two. a greeting program based on a text box

The program source code is as follows:

< script language= "Javascript" >

Function textprintdown () / / Custom run function

{

Var textmesg=prompt ("Please enter your name, thank you very much!" , ") / / set the user input box

Document.form1.textfield.value=textmesg+, welcome to visit us! / / A pair of text boxes are appended

}

Textprintdown () / / run the custom operation function

< / script >

This program is basically the same as the previous program in writing ideas, but there are some differences when embedding web pages. The greeting program built on the layer can simply copy the program code into the source code area of the web page, while the greeting program built on the text box, in addition to the COPY source program, must also add the following HTML code to the source code area of the web page:

< form name= "form1" > < input type= "text" style= "BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; BORDER-LEFT: 1px solid; BORDER-BOTTOM: 1px solid;border-color:white;font-size:12pt;font-family: Song" name= "textfield" >

In fact, the webpage greeting program can not only be written in JAVAscript, but also can be realized in ASP,PHP technology. Although the greeting program written in the latter two languages is more functional, it is undeniable that the greeting program written in JAVAscript is much simpler.

At this point, I believe you have a deeper understanding of "how to achieve Mini Program to greet visitors with Javascript". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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