Recommended: ASP tutorial for beginners: Commonly used ASP built-in functions Functions are a function block encapsulated by the language to facilitate user calls. For example, now() is a function in VBScript that can display the current date and time. As for the specific reason why it can be displayed, it is determined by the language kernel, and the user only needs to
ASP example: Use ASP to write a more user-friendly pop-up program to help us create a non-annoying investigation method.
Using pop-up windows to display questionnaires is considered to be the most convenient and fast way to collect user information. After the first questionnaire was created, we kindly asked people if they were willing to fill out the form, but the results were disappointing. So we decided to put this questionnaire on our homepage and pop up automatically when people visit, and the effect is unexpectedly good.
Here are our secrets to success:
1: The automatic pop-up window can only be displayed once, regardless of whether the user has filled out the questionnaire.
2: The automatic pop-up window cannot affect the display speed of the home page.
3: The automatic pop-up window will automatically disappear after the user fills in the questionnaire.
4: The automatic pop-up window is displayed on the upper left side of the screen.
5: Do not add ads in the automatic pop-up window, because our purpose is to get user survey reports.
To determine whether the window is popped up, we used a small cookie. We define a cookie that can be used multiple times and judged multiple popups. We name this cookie s, which contains the ids of all the windows that have been popped up.
Now, when the user visits the home page, we determine whether the requested id is already included in the cookie. If the cookie does not exist, we pop up the window and write the cookie to prevent the window from popping up again.
In the following example, we write cookies on the server side, which can be achieved using JavaScript. We chose the server side because it is relatively simple.
At the beginning of our homepage, we execute the asp code. This code should be placed before HTML output because we need to edit the header.
| The following is the quoted content: <% Dim bSurvey ' Whether to display the questionnaire const bID=1 ' id of the questionnaire bSurvey=false ' Check if the questionnaire has been shown if instr(request.cookies(s),: & bID & :)=0 Then ' The questionnaire does not show, update cookies ' Set the cookie expiration time to 60 days response.cookies(s).expires = DateAdd(d,60,now()) ' Set the path response.cookies(s).path = / ' Write cookies response.cookies(s) = request.cookies(s) & : & bID & : bSurvey=true end if %> |
We give each questionnaire an id, and if you have multiple popups, it can be easily planned for output.
We add an asp script at the end of the page to determine whether the pop-up window is displayed. This script is at the end of the page and will not affect the download speed of the home page. This script is very simple, it uses window.open() to open a new window.
| The following is the quoted content: <% if bSurvey then %> <SCRIPT> window.open(/survey/displaysurvey.asp?q= & bID,SURVEY,width=350,height=400,top=0,left=0,scrollbars=yes) </SCRIPT> <% end if %> |
Share: Getting started with ASP: Understand several scripting languages used by ASP programs You cannot see the ASP source code by viewing the source code in the browser. You can only see the results output by the ASP file, and those are just pure HTML. This is because the script has been executed on the server before the result is sent back to the browser. Example: Use