Using ASP to write a more humanized pop-up window program

Source: Internet
Author: User
Tags set cookie window

ASP example: The use of ASP to write a more user-friendly pop-up window program, to help us create a not annoying method of investigation.

Using pop-up windows to display questionnaires is considered to be the easiest and quickest way to gather access to user information. When the first questionnaire was produced, we politely asked people if they would like to fill out the form, but the result was disappointing. So we decided to put the questionnaire on our homepage, and when people visit it automatically pops up, the effect is surprisingly good.

Here is the secret of our success:

1: Automatic pop-up window can only be displayed once, regardless of whether the user filled out the questionnaire.

2: Automatic pop-up window does not affect the display speed of the home page.

3: Automatic pop-up window after the user fills out the questionnaire, automatically disappear.

4: The Automatic pop-up window appears on the top left of the screen.

5: Automatic pop-up windows do not add ads, because our goal is to get the user's investigation report.

We used a small cookie to determine whether to pop the window. We define a cookie that can be used more than once and to judge multiple pop-up windows. We named this cookie "s", which contains the IDs of all the windows that have been ejected.

Now, when the user accesses the home page, we determine whether the requested ID is already contained in the cookie. If the cookie does not exist, we pop the window and write the cookie to prevent the window from popping again.

In the example below, we write cookies on the server side, which we can do with JavaScript, and we choose the server side because it's simpler.

At the very beginning of our homepage, we execute the ASP code. This code is to be placed before the HTML output because we need to edit the header.

The following are the referenced contents:
<%
Dim Bsurvey ' Whether to display questionnaires
The ID of the const bid= "1" questionnaire
Bsurvey=false
' Check whether the questionnaire has been shown
If InStr (Request.Cookies ("s"), ":" & BID & ":") =0
Then
' Questionnaire not shown, update cookie
' Set cookie expiration time of 60 days
Response.Cookies ("S"). Expires = DATEADD ("D", 60,now ())
' Set path
Response.Cookies ("s"). Path = "/"
' Write Cookie
Response.Cookies ("s") = Request.Cookies ("s") & ":"
& BID & ":"
Bsurvey=true
End If
%>

We give each questionnaire an ID, and if you have more than one pop-up window, you can easily have the planned output.

We add an ASP script at the end of the page to determine whether the pop-up window, this script side at the end of the page, does 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 are the referenced contents:
<% 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%>



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.