The Page Counter component creates a PageCounter object that counts and displays the number of times a Web page has been opened. At regular intervals the object writes the number of hits to a text file.
Creating a Page and Adding the Page Counter Component Code
- On a Web server running Internet Information Services (IIS), start FrontPage and then open a Web.
- Start a new page. To do this, click the New Page button on the FrontPage toolbar.
- Switch to HTML view.
- Insert the following code before the opening <body> tag to create an object for the counter, to increment the hit count, and to store the hit count in a variable:
<% Dim lngHits Dim objCounter Set objCounter = Server.CreateObject("MSWC.PageCounter") objCounter.PageHit lngHits = objCounter.Hits Set objCounter = Nothing %>
- Switch back to Normal view.
Using the Hit Counter on the Page
- Type You are visitor followed by a space.
- Insert an HTML Markup Web component and add the ASP code that will use the hit counter object.
To do this, perform the following steps:
- On the Insert menu, click Web Component.
- In the Component Type list, click Advanced Controls.
- In the Choose a control list, click HTML.
- Click Finish.
- In the HTML Markup dialog box, type the following code:
This code retrieves the current hit count that is stored in the variable created in the code example in Step 1.
<%=lngHits%>
- Click OK to close the HTML Markup dialog box.
Saving and Previewing the Page
- On the File menu, click Save.
- Name the file CounterText.asp and click Save.
- On the File menu, click Preview in Browser.
- Click Preview.
NOTE: Because the output from the counter object is text, changing the fonts or colors for the page also changes the counter.
For more information about changing the fonts or colors, click Microsoft FrontPage Help on the Help menu, type fonts or colors in the Office Assistant or the Answer Wizard, and then click Search to view the topic.