Lisa Wollin

  • Update

    It's been a long time since I posted.  There are many reasons for this, but mostly, I'm not working with FrontPage anymore.  For the next release of FrontPage, there are a lot of changes happening.  One of the largest is a stronger focus on SharePoint and SharePoint site design and development and less focus on Web development. You can read more about the changes to FrontPage for the next version in Rob Mauceri's blog. I haven't been working with FrontPage nearly as long as Rob, but I have worked with several other Web development apps, and the changes that they made to the FrontPage code this time around are, in a word, incredible. Rob explains what these features are, so I won't go into detail. Please look at his blog for more information

    However, as a result of these changes, they didn't really need me anymore. Since I write about code and developer stuff and not so much about design or UI stuff, so I've gone back to working on Word for the time being. As a result, I won't be posting anymore about FrontPage (thus the name change), but I won't be posting about Word either, so this won't become a Word programming blog. (I actually think there are plenty of those, Brian Jones blog being the predominant one for Office 12 changes.) I'll just write about the things that interest me. The next time I post something I've been doing lately.

  • Online JavaScript Calculator

    There are many online calculators. You've probably seen, and perhaps used, several. Some calculate mortgage payments, others calculate costs, and even more calculate goofy things, like the number of days, hours, minutes, and seconds since you were born.

    Here's a calculator that calculates ... well ... anything. It's a Windows-like calculator that's similar to the one you have in your wallet that lets you calculate how much money you have left in your checking account after you write a check.

    Here's a picture.

    When you use this calculator with the ShowModalDialog method (explained in greater detail in my blog post Open a page in a new window of a specific size), you can return a calculated value to the calling page. Here's how it works: you provide a link to the calculator from a Web page that references a JavaScript function that uses the ShowModalDialog method; then when a user closes the calculator, the total is returned to the first page through the JavaScript function that called the ShowModalDialog method.  It's really much more simple than it sounds.

    Here's some of the code

    In the example page, the "Calculate Numbers" link, code shown below, references a JavaScript function named OpenCalculator.

    <a href="javascript:OpenCalculator();">Calculate Numbers</a>

    The OpenCalculator function, shown in the following code, does a few different things: it displays the calculator, returns a value from the calculator, and places the returned value into a <span> tag.

    function OpenCalculator()
    {
      var ret;
      var spanTag;

      ret = window.showModalDialog(
        "calculator.htm", "",
        "dialogHeight:285px;
        dialogWidth:215px;
        resizable:yes;");

      spanTag = document.all.tags
        ("span").item("numbers");
      spanTag.innerText = ret;
    }

    The calculator has several functions, too many to show here, and three global variables. The global variables store the numbers and operators that the calculator needs to calculate the values. The variable named total stores the current number that is being calculated. When a user clicks the equals button, total resets to zero. The variable named op stores the operator so that when the user clicks the plus button, the calculator knows to add the numbers. The last variable, named isNew, is a Boolean that indicates whether to reset the calculation to zero.

    Each of the buttons in the calculator calls a JavaScript function: the number buttons call the SetNumber function, the operator buttons call the SetOperator function, and the equals button calls the SetTotal function. Each of these functions serves a very specific purpose, but the function that does all the work is the Calculate function, shown in the following code. The Calculate function takes the current operator (the operator button clicked last) and calculates the last number entered (or the value in the number textbox) and places the calculated value into the total variable.

    function Calculate()
    {
      var num = parseInt(document.Calculator.numbers.value);
      
      switch(op)
      {
        case "plus":
        {
          total += num;
          break;
        }
        case "minus":
        {
          total -= num;
          break;
        }
        case "multiply":
        {
          total *= num;
          break;
        }
        case "divide":
        {
          total /= num;
          break;
        }
        default:
        {
          break;
        } 
      }
      
      document.Calculator.numbers.value = total;
    }

    For an example of the calculator and the full code, see the example page.

  • Blog Comments

    I usually always try to respond to comments to my blog, but lately, we've had some disconnects with comments being sent in email, so I thought I would respond to a few recent comments. If I've missed your comment, please forgive me and feel free to send me mail using the Contact link in my blog.

    Comment from Jason:

    "Do you guys purposely markup your pages to render incorrectly in every browser other than IE?

    Jason, I'm not sure if you're talking about the FrontPage dev portal on MSDN or my blog, but I assure you that it isn't intentional. Both the blog tool and MSDN have their own ways of marking up HTML, which are very different from each other and which I haven't yet quite figured out.

    I just tried both MSDN and my blog in Firefox, and the blog looked fine, but sure 'nuf MSDN looked pretty bad. Unfortunately, I can't do much about this, so please don't dis our content because IMHO we have some pretty great content.

    Comment from orcmid:

    "Please screen the most-active newsgroup discussions before you feature them. After reading the thread about multiple body tags, I am very wary of ever asking a question that one of those MVPs might want to tell me is stupid.

    "No one ever did bother to ask what DAWG found valuable about being able to have multiple body tags (regardless of the fact that FrontPage is not designed to allow it), assuming that there was an alternative solution without checking with him what he really wanted to do. The resulting incivility was unpleasant to watch."

    First, newsgroup posts are included using a Web component. I'm not sure exactly how this is determined, but I believe it is based on how many responses there are to a post, so I have no direct control over which posts get "featured."

    Second, no one should ever be treated rudely in any of the newsgroups. The newsgroups are moderated by MVPs and other users who volunteer time to respond to customers. Although we have no control over what general users say, we do have some control over how MVPs treat customers.  I'll forward your comment to the MVP lead, who I'm sure will follow up appropriately with the MVPs. If you ever see any user being abused, called names, or generally treated like an idiot in any of the newsgroups, feel free to contact me, and I'll follow up with the MVP lead.

    Finally, I wanted to address DAWG's issue about using multiple BODY elements in the same document. The HTML schema doesn't allow for multiple BODY elements, so it's not surprising that FrontPage doesn't support it. However, I can think of a couple reasons why someone might want to use multiple BODY elements.

    In documentation, there is something called single-sourcing. It allows people to create one file that can be used in multiple places. For example, you might have some files that you want included in a book as well as in a compiled help file. If this is what DAWG wanted to do, his best choice would be XML.

    Old-timers often associate XML with literal data, as you might find in a database, but XML has many more uses, and single-sourcing is one of them. XML allows you to create a custom schema that you can use to markup content.

    With XML, you can markup the content in a file and specify where different portions of the content get published. As in the case I cited earlier, say you have help files that you want published to a compiled help file as well as in a book.  Another case where you might want to do single sourcing is where some content gets published to a Web site, some content is included in a marketing flyer, and some content is compiled into a brochure. These are only a few instances where XML is the ideal markup language, and I have no doubt that many of you can think of many more possible scenarios where a single file might be published in multiple formats.

    Although XTHML is similar to XML in the sense that the XHTML schema generally encourages that the formatting be kept separate from the HTML, it isn't XML. It's really just an HTML schema that enforces certain style restrictions. True XML uses a custom schema that contains custom markup tags. You use XSLTs to "transform" the appearance of the content in XML files, but XSLTs do more than just change the appearance of the text, for example making some text bold and other text underlined.

    XSLT allows you to convert an XML file from one format, or XML schema, to another. For example, you can use an XSLT to compile XML files into a Word document, or you can use XSLT, to convert files into HTML format. You can even use XSLT to convert from one XML schema to another XML schema.

    The second reason that I can think of is for browser compatibility.  For example, perhaps DAWG wanted to put in multiple BODY elements with the idea that only the BODY element for the client browser would be visible. This seems to me to be the least likely of the two reasons that I can think of.

    Ideally, all Web pages should be cross-browser compliant (MSDN pages not withstanding!), but in the case where you need to develop different HTML pages for different browsers (or connection speeds), you could have a script that determines the browser on load and serves up the correct page for that browser. I'm sure there are several scripts available on the Internet, in fact, I believe FrontPage 2003 includes a behavior for just this purpose, but I'll provide a simple script in a future post for those who are interested in knowing how to do this.

    Thanks, everyone, for your comments. As I said, as much as possible I like to respond to comments and usually do so in email when an email address is provided. Keep the comments coming!

    Until next time, happy surfing!

  • Working with Access databases that live outside of a Web site

    We had a customer recently, who needed to access an Access database from both a classic ASP page and from another Access database. To prevent the database from being locked by IIS, the customer wanted to know if they could move the database out of the Web site directory. By default, FrontPage expects the database to be in the Web site. However, when they did this, it seemed to break FrontPage’s ability to work with the database connection as Front Page.

    Bernardo Iturriaga Dubost, one of the FrontPage testers, came to the rescue of this customer. Here's his response:

    The main reason that FrontPage stores the .mdb files in the web is so that you don’t need to access to the Web server to access the data in a database. However, you can provide dual access to a database by using a system DSN, and then using the DSN in FrontPage to connect to the database. Here's how:

    First, you need to create a system DSN on the Web server that hosts the Web site:

    1. From the Start Menu, click All Programs.
    2. Select Administrative Tools, and click Data Sources (ODBC).
    3. Go to the System DSN tab.
    4. Click Add.
    5. Select the appropriate driver type (for example, MS access driver).
    6. Click Finish.
    7. Provide a name and a description for the DSN.
    8. Click Select the navigate to the actual .mdb file located in another folder on the server.
    9. Click Ok when you're finish selecting the database.
    10. In most cases this is enough, but if the database requires a password, you'll need to provide one. To do this, click Advanced and provide the password.
    11. Click Ok again to create the DSN.

    After you're finished, you'll see your new named DSN listed on the System DSN tab of the ODBC Data Source Administrator.

    Next, you need tell FrontPage to use the DSN to connect to the database.

    1. Start FrontPage and open the Web site.
    2. From the Tools menu, click Site Settings.
    3. On the Database tab, click Add.
    4. In the dialog select System Data source on web server.
    5. Click Browse. FrontPage displays a list of system DSN on the Web server.
    6. The connection that you created in the previous steps should be there, select it and click Ok.
    7. Click Ok to the Site Settings dialog box, this will add the connection string to the global.asa file in the Web site.
    8. You can now use this connection to the database for database features in FrontPage for both ASP and ASP.NET.

    Please note that in order to do this, you need to have access to the actual server that hosts the Web site. One benefit of this configuration is that you can have different permissions for the Web site and for the folder that contains the .mdb file. Please also note that for the users to get data when they browse, MACHINENAME_IUSR needs to have the appropriate read/write access permissions to the .mdb file; otherwise there will be an error.

  • JavaScript 101: Working with Events

    It has been awhile since my last JavaScript 101 post. I apologize. I have a very lame excuse: I've been busy. But I'm back with the next installment: working with events.

    Most JavaScript events are relatively simple and easy to use. For example, clicking on a button, an element, or a page. There are some more complex events that deal with data, but to keep this simple, I'll talk only about the ones that affect user interaction, such as onclick, onmouseover, onmouseout, and onfocus. There are, of course, many more events than this, but these four events seem to cover a majority of the uses that you will need ... at least to start with.

    The Script

    First, of course, you need a script, so here's a simple little script.  All it does is display a message box.  Just copy the code below, including the opening and closing <script> tags, and paste them into the HEAD section of a Web page.

    <script language="javascript">
    function ShowMessage(text)
    {
        window.alert(text);
    }
    </script>

    In order to call a script from an event, it must be inside a function, so the above script contains a function called "ShowMessage" that takes one argument, the text to be displayed.

    Note   As I mentioned in my last JavaScript 101 post, you can use IntelliSense in Code view in FrontPage to write your scripts.

    The HTML

    Second, you need to reference the function from an event inside of an element. I'll use a P element. Here's the HTML code that you need.

    <p>Here is a sample paragraph 
    with an event.</p>

    Putting Them Both Together

    Next, add to the P element a an event handler that calls the function.  You can add it to any event, such as the onload event, but to make things simple, add it to the onclick event.  Here's the code:

    onclick="ShowMessage
    ('A little JavaScript fun!');"

    Your P element should now look like the following code:

    <p oncl­ick="ShowMessage
    ('A little JavaScript fun!');">
    Here is a sample paragraph with 
    an event.</p>

    And that's it.  Save your page and display it in the browser.  When you click on the text in the paragraph, the browser displays a message like the one in the following image.

    What You've Learned

    In this post you learned how to hook up a JavaScript function with an event handler for an HTML element. Now that you understand how to hook your scripts up to events to create user interaction, we can move onto writing more scripts.  Next time, I'll talk about working with text—things like changing the text or HTML in an element, changing colors, formatting, etc. Until then, have fun!

  • New FrontPage Developer Portal ... Sort Of

    During the past several months (about eighteen, to be exact!), we've been working to redesign the FrontPage Developer Portal on MSDN. If you've ever designed (or redesigned) a Web site, you understand the challenges that can arise. After several starts and stops, a great deal of research, and many discussions with stakeholders across Microsoft, I'm really excited to finally be taking the newly redesigned portal live.

    This redesign encompasses some fairly large changes.

    Portal Home Page

    If you visited the FrontPage Developer Portal prior to our redesign, you may have used links on the portal home page to navigate through the other pages within the portal. We removed the links from the main part of the home page and inserted content from and links to other important information, such as FrontPage blogs and popular newsgroup posts.

    Another major addition to the home page is the profile section. In the profile section, we'll introduce you to FrontPage product team members and MVPs. They are people who develop or support FrontPage. Some of the names may be familiar because you may have seen them in the newsgroups; others may be new to you because they generally work behind the scenes. However, all of them are important to FrontPage users as they work daily to build a better product.

    Navigating the Portal

    Because we removed the navigation links from the home page, you might be wondering how you can access the pages within the portal. To navigate the portal, you can use the right navigation bar. The right navigation was always there, but we’ve enhanced it to make it even more useful. It lives on each page in the portal, so you can always get to any page in the portal from any other page. This feature makes navigating the pages simple and easy.

    Getting Started

    The Getting Started page was one of the highest hit pages in our portal, so we redesigned it to really help you get started. It explains the three main pillars around which FrontPage 2003 was developed and provides links to help content, product information, developer articles, and other Web sites where you can find more information.

    Technical Articles

    The Technical Articles page previously listed all technical articles under two main headings: Web development and extending FrontPage. Now the articles are organized according to technologies, so if you want information relating to JavaScript, CSS, or VBA, you can easily find just the articles that you want without having to navigate a huge list of articles on every possible subject except the one in which you are most interested.

    Information Center

    In our research, we found that our customers often wanted information that didn't necessarily belong in an article. But if the information didn't belong in an article, where did it belong? Enter the Information Center. The Information Center comprises pages that explain various Web technologies that Web developers often use as well as tasks that they want to perform.

    The Information Center is probably the area of the redesign about which I'm most excited. Each of the pages in the Information Center covers a major technology or a specific task. For example, if you want information on cascading style sheets, you can go to the CSS information page to find general information, a list of articles in the MSDN library, and other resources and Web sites that contain more information on CSS.

    Initially, we included the Web technologies that are most common for our users: CSS, JavaScript, ASP, ASP.NET, and databases; and we included one major task: e-commerce. We plan to add additional pages in the future.

    You can get to all the pages in the Information Center from the right navigation bar. In addition, there are links to many of the Information Center pages from the technical articles page.

    How Can You Help?

    We redesigned the FrontPage developer portal for you. We looked at which pages received the highest hits; we determined where you were going from the portal; and deduced (based on search and metrics) what information you wanted most.

    You can help us by telling us how we're doing and what we can do to improve. We've added ratings to several of the portal pages to help you tell us what you think. As we receive actionable feedback, we'll make changes and continue to evolve the FrontPage developer portal.

    We have one goal in mind: make the FrontPage developer portal the place you go to find information relevant to what you do—develop Web sites with FrontPage.

  • Password Protecting Web Pages

    John Jansen, one of the FrontPage testers, sent me these three different ways to password protect pages in FrontPage.

    Using a FrontPage site template and ASP
    Using Code Snippets
    Using ASP.NET

    To password protect pages using a FrontPage site template and ASP

    Here are specific steps to password protect pages using features built into FrontPage:

    1. From the File menu, click New.
    2. From the Web Site tab, select FrontPage Server Templates from the first list, and then select Database Interface Wizard from the second list.
    3. Type the location where you want to put your password protected page. This must be an Windows Web server running IIS.
    4. Click OK.
    5. In the Wizard…
      1. Click Next to create an ASP solution.
      2. Click Next to use the default name for the connection.
      3. Click Next to use the default columns in the table.
      4. Click Next after the DB is created.
      5. Click Next to use the default table.
      6. Check the box to use a Database Editor.
      7. Click Next.
      8. Choose a password and enter it.
      9. Click Next.
      10. Click Finish.
    6. After FrontPage finishes building the site, all of the necessary code for password protecting pages has been generated. In order to protect any new pages, simply put the following code:
      <!-- #include file=”login.asa” -->
      <%
      If Session(SiteId) <> true Then
      Response.Redirect(“login.asp?requester=<!--insert page name here-->”)
      End If
      %>
      above the <HTML> tag on any page and save as .asp.

    To password protect pages using Code Snippets

    Here are steps to create password protected pages using code snippets:

    1. Create a new site in FrontPage.
    2. Create a new page and switch to Code view.
    3. Delete all the code in the new page.
    4. Paste the following code as a code snippet.
      <%
      Username="user"
      Password="pass"
      ' if any of the variables do not match, create error message
      if Request.Form("login") <> Username or Request.Form("password") <> Password then
          MsgErr = "<h3>Authorization Failed.</h3>"
          Response.Write MsgErr
          ' if correct, set the session variable and proceed
      Else
          Session("someStringValue") = true
          ' redirect
          If Len(Request("requester")) > 0 Then
              Response.Redirect (Request("requester"))
          Else
              Response.Redirect "protected.asp"
          End if
      End if
      %>
      <html>
      <head>
          <title>Results -- Login</title>
          <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
          <meta name="GENERATOR" content="Microsoft FrontPage 6.0">
          <meta name="ProgId" content="FrontPage.Editor.Document">
      </head>
      
      <body bgcolor="#FFFFFF">
          <FORM ACTION="login.asp" METHOD="post">
          <h3>Login</h3>
              <TABLE BORDER=0> 
                  <TR>
                      <TD ALIGN="right">User name:</TD>
                      <TD><INPUT TYPE="text" NAME="login" size="10" VALUE=''/></TD>
                  </TR>
                  <TR>
                      <TD ALIGN="right">Password:</TD>
                      <TD><INPUT TYPE="password" NAME="password" size="10" VALUE=''/></TD>
                  </TR>
                  <TR>
                      <TD><input TYPE="hidden" NAME="requester" VALUE="<%=Server.HtmlEncode(Request("requester"))%>"></TD>
                      <TD></TD>
                  </TR>
                  <TR>
                      <TD align="left"><INPUT TYPE="submit" VALUE="Login"/></TD>
                      <TD></TD>
                  </TR>
              </TABLE>
          </FORM>
      </body>
      </html>
    5. Save page as login.asp.
    6. Create a new page and switch to Code view (or do this with any page you want to protect with a password).
    7. Above the opening <html> tag, paste in the following snippet.
      <%
      If Session("someStringValue") <> true Then
          Response.Redirect("Login.asp?requester=protected.asp")
      End If
      %>
    8. Save this page as protected.asp (or replace the requester text above from protected.asp to the page name you are protecting).
    9. Browse to protected.asp.

    To password protect pages using ASP.NET

    Here are steps to password protect pages using ASP.NET:

    1. Create a new page in your Web site and switch to code view.
    2. Select and delete all the code in the page.
    3. Paste in the following code.
      <html>
      <body>
          <h1>Please Log In</h1>
          <hr>
          <form runat="server">
          <table cellpadding="8">
              <tr>
                  <td>User Name:</td>
                  <td><asp:TextBox ID="UserName" RunAt="server" /></td>
              </tr>
              <tr>
                  <td>Password:</td>
                  <td><asp:TextBox ID="Password" TextMode="password" RunAt="server" /></td>
              </tr>
              <tr>
                  <td><asp:Button Text="Log In" OnClick="OnLogIn" RunAt="server" /></td>
                  <td></td>
              </tr>
          </table>
          </form>
          <hr>
          <h3><asp:Label ID="Output" RunAt="server" /></h3>
          </body>
          </html>
          <script language="C#" runat="server">
              void OnLogIn (Object sender, EventArgs e)
              {
                  if (FormsAuthentication.Authenticate (UserName.Text, Password.Text))
                      FormsAuthentication.RedirectFromLoginPage (UserName.Text, false);
                  else
                      Output.Text = "Invalid login";
              }
          </script>
    4. Save the page as loginpage.aspx.
    5. Create a new page and switch to code view.
    6. Select and delete the code in the page.
    7. Paste the following code into the new page.
      <configuration>
          <system.web>
              <authentication mode="Forms">
              <forms loginUrl="LoginPage.aspx">
              <credentials passwordFormat="Clear">
          <user name="Bruce" password="Batman"/>
          </credentials>
          </forms>
          </authentication>
          <authorization>
          <deny users="?" />
          </authorization>
          </system.web>
      </configuration>
    8. Save the page as web.config.

    And that’s all there is to that. Any aspx pages in the same folder as the web.config file are protected.

  • JavaScript 101: Writing Your First Script

    You can arm yourself with all the background information that you want, but the easiest way to learn JavaScript is to just jump in and start writing code. So let's start with something simple for your first script.

    The window object contains all the other objects in the DOM, plus properties, methods, and events for the browser window. A common task that people want to do is specify the text for the status bar. Here's a simple bit of code that does this.

    window.status = "This is a sample for changing the text on the status bar."

    This example is very simple, but simple is a great way to start.

    Now that you have the code, what do you do with it? This is a great beginner question. There are two ways to insert JavaScript code into your pages. (1) You can insert raw JavaScript code into a <script> tag in the HEAD section of a page. (2) You can place the code in a function and put the function in a <script> tag in the HEAD section of a page, and then add an event handler to call the function.

    (1) insert raw JavaScript code

    For now, let's stick with the simplicity of the first option. Use the following steps to add this code to a page.

    1. Start a new page in FrontPage and switch to Code view. (You can also use the code window in Split view.)
    2. In Code view, locate the closing </head> tag. (If you don't know HTML, there's never been a better time to learn. Check out the HTML tutorials on Office Online and HTML for Beginners on MSDN.)
    3. Press Enter a couple times and position the Insertion Point (cursor) on one of the blank lines.
    4. Copy the following code and paste it into FrontPage at the Insertion Point.
      <script language="javascript">
      window.status = "This is a sample for changing the text on the status bar."
      </script>
    5. Save the page and preview it in a browser. Your page should look just like the following image (status bar text is circled in red to make it easy to locate).

    The second way to insert a script (i.e., place the code a function and put the function in a <script> tag in the HEAD section of a page, and then add an event handler to call the function.) requires a bit more work, so let's split it up into three separate tasks

    (2) place the code in a function

    Put simply, a function is a section of code that runs separately from code around it. Essentially, functions are methods that you create yourself to perform some action or series of actions. Some functions return values; other functions require values passed into them. The values that functions return are called return values; values passed into functions are called arguments.

    The structure, or syntax, of a function is always the same: the function keyword identifies that what follows is a function, the text that follows the function keyword identifies the name of the function, the name of the function is followed by opening and closing parentheses (which may or may not contain arguments), and the code that applies to the function appears inside of opening and closing curly braces.

    Here's a simple diagram of the syntax of a function:

    For those of you who prefer to cut and paste, here's a code version of the above.

    function scriptName()
    {
        //Code goes here
    }

    Using the example above, your function might look something like the following code.

    <script language="javascript">
        function changeStatus() 
        { 
            window.status = "This is a sample for changing the text on the status bar."
        }
    </script>

    When you place JavaScript code in functions, you can call the functions from event handlers. Event handlers execute code based on certain events that occur within the browser. I'll talk more about events and event handlers in my next post; for now, I want to show you how IntelliSense in FrontPage can help you write scripts.

    Using IntelliSense in FrontPage

    IntelliSense provides cues to options (or in this case objects, methods, properties, and events) that may be available. Let's go back to the code that we used earlier and create this again in FrontPage (without cutting and pasting the code).

    Using IntelliSense to insert HTML Elements

    1. To begin, start FrontPage and start a new page.
    2. Switch to Code view.
    3. Position the Insertion Point (cursor) before the closing </head> tag and press Enter a few times.
    4. Move the Insertion Point up a couple lines and type "<s". As you type, a drop-down box, as shown in the following image, displays showing a list of elements that can be placed within the HEAD section of a Web page.

      As you type, the highlighted element moves to "script"; at this point you can press the spacebar (or Enter or Tab) to insert the element into your Web page.
    5. After you press the spacebar, you see a list of attributes that apply to the SCRIPT element. Type "langu"; again, as you type, the highlighted attribute changes from lang to language. (We need the language attribute to identify that we are using JavaScript.)
    6. When the language attribute is highlighted, type an equals sign (=) and a double quote (").
    7. Now you see a list of possible values for the language attribute. Type "j", and the highlighted value moves to "javascript".
    8. Type a closing double quote (") and a closing angled bracket (>). FrontPage automatically inserts the closing </script> tag.
    9. You should now have the following code in your Web page:
      <script language="javascript"></script>

    When you use IntelliSense to insert HTML elements, FrontPage places the Insertion Point between the opening and closing tags. You can then type text or, in this case, code between the tags.

    Using IntelliSense to write JavaScript code

    Now that you have an opening and closing script tag, you can write your script code.

    1. With the Insertion Point between the opening and closing <script> tags, press enter a couple times. Arrow up once so that your Insertion Point is on the line that is between the line that contains the opening script tag and the line that contains the closing script tag.
    2. Type "window."; don't forget the period after the window. Once you press ".", FrontPage shows a drop-down list that contains all the properties, methods, and events related to the window object, as shown in the following image.
    3. Type "st" and then press Tab. FrontPage inserts "status" into your script. Now your script should read: window.status
    4. Press the space bar and type an opening quote.
    5. Type "This text displays on the browser's status bar.", and then type a closing quote.

    The only thing to understand about using IntelliSense for writing scripts is that IntelliSense doesn't work when you are working with variables because FrontPage doesn't know which object a variable represents. I'll tell you more about declaring and working with variables a bit later. For now, try using IntelliSense to insert your own simple scripts. Here are a few to get you started:

    • window.alert("here's a message");
    • window.resizeTo(640,480);
    • window.moveTo(0,0);

    These are just a few simple scripts; in a future post, I'll help you understand how to write your own more complex scripts.

    Here's what you learned today:

    • Woohoo! You wrote your first scripts.
    • You learned how to use IntelliSense in FrontPage.
    • You learned how to create a JavaScript function.

    In my next post, I'll tell you more about events and how to connect a JavaScript function to an event on a Web page. For now, have fun.

  • IE User Agent

    I apologize for not posting much lately. I have the next installment of JavaScript 101 almost ready and will post it as soon as I have a chance to finish it. I've been hard at work writing the doc plan for the next version of FrontPage. No, I can't share what's planned (for articles or features), but I will eventually. Please be patient.

    In the meantime, I wanted to share with you the IE blog. If you haven't seen the IE blog, you might want to keep an eye on it. There's an interesting post about the Internet Explorer 7 User Agent String that might be important to Web developers who have code that sniffs out the client browser. As explained in this post, you may need to make a change to your code to be compatible with newer versions of IE.

  • JavaScript 101: The JavaScript Object Model

    If you talk to several different Web developers, each will probably see the JavaScript object model differently. To make it easiest, I'm going to split the JavaScript object model into two separate entities. One is the DOM, or Document Object Model, and the other is "everything else."

    The DOM

    Let's first start with the DOM. The DOM, also sometimes called the DHTML object model, is generally used to create dynamic HTML (DHTML). The DOM is made up of objects and members (by "members" I mean methods, properties, and events) that allow you to change the appearance of a Web page by using code. A drop-down menu is an example of using scripting with the DOM to manipulate the visible state of a DIV element. The following image shows the core objects in the DOM.

    Periodically, I'll refer back to this image as I break down the different objects of the DOM. For now, just notice the hierarchical structure of the DOM.

    Different browsers implement the DOM differently. For example, an object that you can access in one browser may not be available in another browser. The above diagram includes only core objects and not custom objects that are included only in one or a few browsers. For example, the Layer object only works in Netscape Navigator, and possibly Mozilla and Firefox by association, and not in Internet Explorer. By the same token, Internet Explorer may implement its own custom objects that are unavailable in non-Microsoft browsers. For this reason, if you want your scripts to run in all possible browsers, you should stick with the core objects and not use custom objects, which may make programming scripts easier but will cause problems for your users.

    Scripting against objects or using methods, properties or events that are not implemented in all browsers causes a run-time scripting error, like the one shown in the following image, when displaying a page in a browser in which the object or member is not available.



    You have probably seen similar error messages. Sometimes, the cause is that there is an error in the code, but most often, the programmer scripted against an object or member that isn't available in your browser.

    Everything Else

    Next, the "everything else" that I mentioned.  Everything else includes objects to handle strings, numbers, and boolean values as well as mathematical functions and arrays. I generally consider these less "objects" and more as language conventions and built-in functions, but I'll explain that a bit later. For now, I'd like to focus on working with the DOM since those are the objects that most client-side JavaScript uses (although you can use the math functions to calculate numbers, which you might get from a Web form, but that's a subject that deserves its own post, so for now forget I mentioned it).

    Working with the DOM

    As I already said, the objects in the DOM are the objects that you would generally use to animate Web pages using client-side scripting. The main top-level object is the window object. All other objects are what are called "child" objects of this object because they exist as "children" of this object. This can be easier to understand if you think of the above diagram like a family tree. The window is the top-level "parent" object with "child" objects named document, event, history, location, navigator, and screen. The document object is a "child" object that is also a "parent" object because it has "child" objects, as does the form object.

    The relationship between parent and child objects in an object model give the objects a structure that you can easily navigate, and understanding this structure helps you determine how to access child objects, which makes editing and writing scripts easier. You can work with most child objects of the window object directly without accessing them from the window object.

    When you access individual objects within this hierarchical structure, you need to separate each object (and/or member) with a period (.). For example, the following code accesses the BODY element of the document object that is a child of the window object.

    window.document.body

    However, as I mentioned above, the document object is one of the child objects of the window object that you can access without first accessing the window object. So this code could also be written as shown in the following code.

    document.body

    Note   You may have noticed that there isn't a body object in the object hierarchy shown in the image. This is correct. You'll also notice that I said that the code accesses the BODY "element" not the body object. The body in the above code is an accessor property that returns an element object. (If you've forgotten what an accessor property is, see my previous post JavaScript and OOP.)

    All HTML elements (with the exception of the elements that have specific objects in the object model, like the STYLE and FORM elements) use the element object. However, not all elements have properties that you can use to access them directly. (In fact, most do not.) The BODY element just happens to be one of the few that does. I'll explain in a future post how to access all the other elements.

    Whew! This was a lot of general, overview-type stuff to take in in one sitting, and you might be thinking what on earth you're going to do with all of it. Well, I don't expect it to gel completely just yet, but soon it will all make sense and you'll be writing your own scripts like a pro.

    For now, here's what you learned today about JavaScript:

    • JavaScript has objects that you can use to animate Web pages (DOM) as well as objects that you can use to calculate numbers, handle strings, and work with arrays ("everything else").
    • The DOM contains objects that you can use to access features in a browser and elements in a Web page.
    • You use the DOM objects to create dynamic HTML pages.
    • The DOM has a hierarchical structure that is similar to a family tree and is made up of "parent" and "child" objects.
    • Understanding the hierarchical structure of the DOM helps you know how to access the appropriate child objects and makes writing scripts easier.
    • In script, you need to separate objects in the hierarchical structure with a period (.).

    In my next post, we'll write a few simple scripts and I'll show you how IntelliSense in FrontPage can help you write your scripts.

  • JavaScript 101: JavaScript and OOP

    As I mentioned in the previous post, JavaScript 101: An Introduction, JavaScript is an Object Oriented Programming (OOP) language, and as such, it is comprised of objects. A bunch of objects bundled together is called an object model, also called an application programming interface (API). Each object in an object model has characteristics that describe it — properties, actions that you can take against it — methods, and actions that happen in response to other actions — events.

    JavaScript is admittedly not as robust as most compiled OOP languages; the object model is simple by comparison, but in order to write, modify, or even reuse someone else's JavaScript code, you should understand the basics of an object model.

    Properties — Properties describe the characteristics of an object. To use the car analogy that I used in the previous post, a car has characteristics, or properties, like make, model, and color. Often, properties have a single value. For example the make property of the car object might have a value of "Dodge"; the model property might have a value of "Durango"; and the color property might have a value of "Red." Properties can also be objects. These are called "accessor properties" because they access another object. In our car analogy, the car object might have a steeringWheel property that accesses a steeringWheel object, and the steeringWheel object may have its own set of properties, methods, and events.

    Methods — Methods are actions that you can take against an object. To continue the car analogy, actions that you can perform with a car might be start, drive, and get a tune up. Some methods return values; other methods require values passed into them. For example, the start method of the car object might return a true or false (boolean value), and the tuneup method might require passing in a date for when the tune up occurs. The values that methods return are called return values; values passed into methods are called arguments.

    Note   The term "parameters" is also often used to refer to the values passed into methods. The actual definitions of these two terms differ somewhat, but a complete discussion of these differences are beyond the scope of this discussion. I'll explain these terms a bit later.

    Events — Events are actions that happen in response to other actions. The car analogy works here, also. For example, the car object might have an event named die to handle the possibility of the engine quitting unexpectedly, or it may have a crash event to handle the possibility if the car is involved in an accident.

    Collections — Another part of an object model is collections. Collections are comprised of one or more instances, or copies, of the same object.  For example, in the car analogy, a car object might have a tires collection that has five instances of the tire object (with one tire object having the isSpare property set to true).

    Don't worry if this all seems confusing. I'll explain properties, methods, events, and collections a bit more when I discuss specific objects in the JavaScript object model. However, before I describe the objects in the JavaScript object model, there are a few things you need to understand first. I will describe some of these in greater detail later, but you will need at least a general understanding of these before moving onto the specifics of the JavaScript object model.

    Variables — In programming, variables are considered temporary storage. The can represent objects or data, such as strings or numbers.

    Data types — Simply put, data type indicates the type of data in a variable. The three basic data types in JavaScript are strings, numbers, and booleans. String variables contain text, number variables contain ... well ... numbers, and boolean variables indicate true/false, on/off, and yes/no conditions.

    Case sensitivity — JavaScript is case sensitive. This means that JavaScript considers the word "doc" and the word "Doc" as two different words and not the same word.

    Arrays — Arrays are variables that contain multiple values of the same type. For example, an array of numbers could contain the values 1, 3, 45, 50, and 69 all within the same variable name. JavaScript programmers frequently use arrays to store multiple values.

    So the things you learned about JavaScript in this post are

    • The JavaScript object model (or application programming interface) is comprised of objects, collections, properties, methods, and events.
    • Properties describe characteristics of an object.
    • Methods perform actions against an object.
    • Events handle actions that are performed against an object.
    • Variables are temporary storage.
    • Data types indicate the type of data contained in variables.
    • JavaScript is case sensitive.
    • Arrays contain multiple values of the same type.

    This is a lot of information, but I think we're through with the basics. Next post, I'll diagram the specific objects in the JavaScript object model.

  • JavaScript 101: An Introduction

    Many visitors to the MSDN FrontPage developer portal are unfamiliar with programming, so I decided that the best way to help non-developers understand our developer content is to provide education. This is the first installment, and its purpose is to teach JavaScript to the non-developer. The JavaScript 101 series is not designed for developers, as most of our developer content is, so it may be far too simple for a seasoned JavaScript developer. However, if you are either new to JavaScript or completely unfamiliar with JavaScript, this series is for you. For a list of all the posts in this series, scroll down the page and click JavaScript 101 under Post Categories.

    Before I start on the programming end of JavaScript, I wanted to explain the purpose of JavaScript and a bit of the background. Last summer, we published an article titled Introduction to Web Development that described the various languages and technologies that Web developers may encounter and need to use. After a description of what programming languages are and how they are used on the Internet, the article gave the following description for JavaScript:

    JavaScript is an interpreted scripting language commonly used on the Internet for creating Web pages that respond to user actions, such as when a user moves a mouse pointer over an image or clicks a form button. Combined with HTML and CSS, JavaScript allows you to create Dynamic HTML pages.

    JavaScript is generally used for client-side scripting; as a result, users can easily view JavaScript code along with the HTML code in a page. Although it may be used for server-side scripting, JavaScript works best for visual animation (such as changing an image when a user moves the mouse pointer over it) or for validating form fields.

    Various browsers may implement the JavaScript scripting objects differently, but most popular browsers support JavaScript.

    The biggest disadvantage of JavaScript is that users can turn it off in the browser, which makes pages that use it not function as expected.

    Netscape developed the JavaScript programming language. JScript is the Microsoft implementation of ECMAScript, as defined by the specification of Ecma International. Both JavaScript and JScript are ECMAScript-compliant languages.

    As the article mentions, there are basically two types of programming languages: compiled and interpreted. Most programs have .exe files. An .exe file is where the code that runs a program lives, and usually you can double-click an .exe file to start a program. (For example, if you use Windows Explorer to locate FPage.exe and double-click it, FrontPage starts.) Compiled programming languages require a language compiler to create the .exe files. Interpreted programming languages aren't compiled into .exe files but require an interpreter to understand the code.

    Much like you may need an human interpreter to understand a natural language (such as Danish or Swahili), browsers need a JavaScript interpreter to understand JavaScript code. As the preceding quote mentions, JavaScript is an interpreted language and a JavaScript interpreter lives inside most browsers, so when you write JavaScript code, you don't need to buy an interpreter to run the code. Instead, the interpreter sees the code and in effect tells the browser what to do with it. Some browsers don't understand JavaScript code. For example, older browsers that were developed before JavaScript was invented obviously wouldn't support it. Plus, most browsers allow the user to turn off JavaScript. In both of these cases, the user wouldn't receive an error; your code just doesn't run.

    Because JavaScript usually runs in a browser, it's also called client-side scripting. You can use other languages for client-side scripting, but no client-side language is as universally accepted as JavaScript or understood in more browsers. This is why most Web developers use JavaScript to animate their Web pages using Dynamic HTML (DHTML). DHTML allows you to respond to the actions of your users; thus the term "dynamic."  For example, when a user moves her mouse over an element on a page, you may want to perform an action, such as displaying an element that was previously hidden (as is usually the case with drop-down menus). Or when a user clicks the Submit button on a form, you may want to verify that he has entered all the necessary information in the fields.

    JavaScript is also termed an object-oriented programming (OOP) language. OOP is a programming paradigm that differs from traditional programming in that it separates elements of an application into discrete elements. I'll explain OOP a little bit at a time, especially as it relates to JavaScript, because it can be quite confusing when taken as a whole; however, the simplest explanation is this: OOP uses objects, and objects are basically things — specifically, things as they relate to an application. For example, think of an object, or thing, that you use every day: your car. Cars have values that describe them, such as make/model and color, and you can perform certain tasks with them, like start and drive them.

    Before you begin pulling your hair out and yelling "I don't care about OOP or that JavaScript is an interpreted language; all I want to do is add this little bit of code to my page," let me assure you that this information is very important. The first JavaScript book I ever read never made one mention of OOP. I felt like I had watched a game and missed the winning play. Without this information you may be able to incorporate scripts that others have written into your page, but you will never be able to troubleshoot the code, and I promise you that you will at some point need to do that. So please bear with me. This introduction (and the one or two topics that follow) is critical to helping you understand what you need to know to not only incorporate scripts into your page but also write a few scripts of your own. However, I promise that this info won't be book-length. I'll include only the information you need to be able to move forward. Promise!

    So the things you learned about JavaScript in this post are

    • JavaScript is an interpreted programming language.
    • JavaScript is a scripting language that you can use for client-side scripting.
    • You can use JavaScript to animate Web pages using DHTML.
    • JavaScript allows you to respond to user actions.
    • JavaScript is an OOP (object-oriented programming) language.

    Next time I'll talk a little more about JavaScript as an OOP language.

  • Tools for Designing Graphics for Web Sites

    In my various lives, I've worn a lot of hats, from teaching to marketing and desktop publishing (back before there were computers for the masses) to writing text and code, and in all those lives, wearing all those hats, I've worked with my share of computer applications. As a teacher, one of the things I told my students was that if you've worked with one Windows application, you can easily transfer those skills to other Windows applications.

    I, personally, think this was true for DOS applications, too, although I'm sure many would disagree, and I think this is true of many, if not most, occupations that changed with the advent of the personal computer. For example, many who worked as desktop publishers for print media became Web designers. In many ways, Web design is very much like print design, and many of the design guidelines for print media apply to the Web ... but they also don't. It's hard to explain without an example.

    One guideline of print media is the importance of white space. Of course, white space isn't always "white" but rather blank or empty space that has no text or graphics. Flip through any magazine and you'll understand what I mean. The advertisements that grab your attention aren't usually those that have a lot of elements on the page fighting for attention; they are usually the ones that have a few and in many cases one main element surrounded by empty space. There may be just a few words attached to an evocative image, usually something that causes readers to feel some emotion, encouraging them to buy whatever the ad is selling. Newspapers are probably the one form of print media that gets away with using up every inch of spare space with text or images, and most do this very well because they coordinate the different elements on the pages so that they all compliment each other.

    On the Internet, white space is still important, but you rarely see Web sites that incorporate huge amounts of it. In fact, the only Web site I know of that truly incorporates white space is Google.com. Most Web sites try to fill up every spare pixel of space. Some do this very well, others very poorly. I would even go so far as to say that either Web sites do it very well or they do it very poorly. There doesn't seem to be a happy medium here. If you look at some of the popular sites, like amazon.com and msn.com, you see sites that are very busy but also very well designed because they coordinate all the elements to create a uniform whole. Even advertising coordinates in color and format with other elements on the page. By the same token, you can probably find exponentially more Web sites that are just as busy but don't coordinate the elements on the page nearly as well. Usually, these pages have multiple flashing ads with several different fonts and a rainbow of conflicting colors. Usually these are the pages that you can't get away from fast enough.

    My point is this: many Web designers and Web developers didn't get started as designers. We didn't take classes and get degrees in design. We sort of grew into it as our jobs changed and grew. We designed a few graphics, and everyone ooh'd and ah'd. We designed a few Web pages, and our bosses called us a Web designer. Most of us, no matter how good we are behind a camera, wouldn't publicly admit that we couldn't draw a straight line if our lives depended on it.

    That's where graphics applications come in. There are a ton of graphics applications available on the market, many (IMHO) so overpriced that even a veteran graphic designer couldn't use them enough to pay for them. However, there are some really good graphics applications available (some relatively inexpensive) that can make even non-designer developer-types look really good. Here are my favorite.

    Paint. Okay, I'll say it again ... Paint. Everyone knows what it is, but many refuse to acknowlege that they use it. Everyone one who has Windows has it, and for the money (free), there are few graphics applications that are better. Okay, so you may not want to create a lot of intensive graphics in Paint, but there are some very cool things that you can do in Paint that you can't do in other graphics applications. For example, let's say you're designing a Web site or developing a Windows application and all you want to do is add a screen shot to a document or modify it just slightly.

    Most if not EVERYONE knows that you can press Print Screen to take a screen shot (Alt-Print Screen to get just the active Window or dialog box), and since this copies a bitmap of the screen to the Windows Clipboard, all you need to do is paste the results into any document. But what if you need to edit it? Perhaps you're writing a spec and need to edit out or change some portion of a dialog to create a new look; perhaps you're creating a training handout that describes portions of an application and need to add callouts. There are a million and one reasons why you might want to edit a screen shot, and I don't know of another graphics application (at least not for the cost of Paint) that allows you to edit a bitmap pixel by pixel.

    Now some of you are probably thinking right about now that you can't use bitmap images on the Internet, and yes, that is true (or rather you can but they're not as good as GIF or JPEG and not useful across platforms, etc.), and while you can save GIF files in Paint, the color fidelity isn't good, so I'd like to introduce you to another tool that costs just about as much as Paint.

    Office Picture Manager. If you have any Office System 2003 application (and if you have FrontPage 2003, you have an Office System 2003 application), you get Office Picture Manager free. Yes, you read that correctly ... gratis. And you can do some pretty nice things with Office Picture Manger. You can save a bitmap as a GIF ... or JPEG ... or PNG ... or TIFF ... or you can save any one of those as any one of the other. You can change the colors, crop, rotate, flip, resize. There is only one thing that you can't do with the current Office Picture Manager that you could do with its predecessor (the one in Office 97, Office 2000, and [I think] Office 2002), and that is specify a transparent color. IMHO this is sad for those of us who work with Web images, but in every other way, the Office Picture Manager included with the Office System is a better application.

    The scenario would go something like this: take a screen shot, paste it and save as a BMP in Paint, open it in Office Picture Manager, and export it into the format of my choice, usually gif. I often use Office Picture Manager to convert bitmap graphics and screen shots that I use in my articles to GIF and to resize them as appropriate to meet MSDN guidelines. Although more recently I've been using a different product, Office Picture Manager is a great choice and definitely a great tool to keep in your toolbox for working with graphics of any kind.

    PaintShop Pro. This is a non-Microsoft graphics program developed by Jasc (www.jasc.com) that I've worked with, and compared to high-end graphics applications like Adobe PhotoShop, it's a terrific application for creating and manipulating graphics of all kinds. I love to use the different effects on photographs and for the money, this is an awesome application. I especially love that I can see what my image looks like with a proposed change before I make it. If I don't like what I'm seeing, all I have to do is click Cancel and my image remains unchanged. I'm sure I don't use it to its full capabilities, but I definitely like to keep it around for working on Web graphics. (As a side note, I actually preferred PSP 7.0 to PSP 8.0, but I have PSP 8.0 because it was the only one available when I purchased, and although it is good, IMHO 7.0 was better.)

    A while ago I found instructions for creating repeating designs, which are great as background images for Web pages, in PSP 7.0. I can't remember if I tried the steps in 8.0, I've since forgotten how, I don't remember the URL, and a quick look at the PSP 8.0 UI doesn't provide any clues, but in 7.0, it was a simple task of selecting part of a larger graphic and selecing a "make repeating graphic" command. I don't see the same command in 8.0, so I don't know if it's possible. However, even with this deficiency (which is relatively minor since I don't use repeating designs on Web pages), PSP 8.0 is an excellent graphics application.

    Picture It. For all the things for which I love PSP, I love Microsoft Picture It, but for working with photographs, I've never worked with a simpler, better application. It has some great tools for cleaning up photos, like adjusting the angle on crooked photos to erasing flaws. About a year ago, I had the opportunity to use it on photos for a furniture Web site, and I was amazed at how well it worked. For photos that had too much glare, Picture It allowed me to cut the glare and deepen the colors to a richer tone; for photos that were too dark, I could lighten them without losing definition. I've never gone googoo gaga over a graphic program, but this one gives me hours of enjoyment.

    Visio. Recently, I've used Visio more freqently for creating images for articles, especially if the image isn't a screen shot, but Visio has a feature (IMO) that is very important for Web designers and developers beyond the ability to create or save images in Web-compatible formats. With Visio, you can create a map of a proposed Web site (which you can probably do in most graphics applications) and you can also map out the structure of an existing Web site just by providing a URL. If this ability exists in other graphics applications, I admit that I've never seen it. I was first introduced to this feature years ago (perhaps even before Microsoft acquired Visio), and I've found it a very useful tool when working with Web sites. As long as a site has pages that have links, Visio can map the structure of the site. The default is 3 levels deep and 300 links, but you can adjust these settings as you need to. Visio is, admittedly, the pricier of the graphics applications listed here, but if you work with multiple Web sites (perhaps as a consultant) or manage a medium to large web corporate site, this one feature alone makes the cost of Visio worth the expense.

    Gif Construction Set. As I said, I've worked with a lot of graphics applications, but this is the only one I've worked with that allows you to create really cool text effects. You can do a lot more with it, like animated gifs (if you've read even a few of my posts, you've figured out how much I "love" animated gifs), but text effects is what I've used it for most. If you've spent any time at all working with Web sites, you know that in order to show special fonts on Web pages, either the visitor needs the font on their local computer or you create graphics to show the font. Gif Construction Set, developed by Alchemy MindWorks (www.mindworkshop.com), allows you to create very cool text effects with any font installed on your computer. You can set shadow effects, create outlined text with fonts that aren't outlined to start with, create scrolling text marquees (okay, yes, an animated gif, but it's text!), and a host of other special effects. For a great price, you get a great tool to add to your toolbox, and if you're unsure whether it will suit you, I think you can still download a demo so that you can try before you buy. (If I'm not mistaken, it's a full working version except that the images have text written across them until you register ... if I'm not mistaken.)

    Of course, these are only a few of the graphics applications available, and most are much more expensive than the ones I've included here, but all of these (IMHO) deserve a place in a professional Web designer/developer's graphics toolbox.

  • Creating a CSS File for your Web site

    Dave Berry wrote an excellent article about Cascading Style Sheets (CSS) on MSDN (Using Cascading Style Sheets on Your Web Site), so I won't bore you with the details of CSS.  However, one reader commented that the article didn't cover how to create an external CSS file.  This is very easy, so here's how.

    Say you have the following embedded style sheet on a page and you want to share the styles with other pages in your site. (See "Three Types of Cascading Style Sheets: External, Embedded, and Inline" in Dave's article.)

    <style>
    BODY
    {font-family: Comic Sans, Verdana, Tahoma, Arial;
    font-size: 10pt;
    margin: 0em;}

    P
    {padding-left: 5;
    padding-right: 5;}

    H1
    {font-size: 11pt;
    font-weight: bold;
    color: white;
    background: #FF3399;
    padding-top: 10;
    padding-bottom: 5;
    padding-left: 10;
    padding-right: 10;}
    </style>

    All you do is copy the contents of the STYLE element (the text between the tags but not the tags themselves) into a new file.  (In FrontPage 2003, you can create a new blank page, display the page in Code view, and paste the CSS code.  In earlier versions, you can either use HTML view or Notepad.)  Then save the file with a .CSS extension.  I usually call the main CSS file for a Web site web.css just for the sake of consistency, but you can name it anything you want.

    The contents of your new file should look something like this:

    BODY
    {font-family: Comic Sans, Verdana, Tahoma, Arial;
    font-size: 10pt;
    margin: 0em;}

    P
    {padding-left: 5;
    padding-right: 5;}

    H1
    {font-size: 11pt;
    font-weight: bold;
    color: white;
    background: #FF3399;
    padding-top: 10;
    padding-bottom: 5;
    padding-left: 10;
    padding-right: 10;}

    Once you have the CSS file, you can remove the STYLE element and it's contents from the first page, and add a LINK element or an @Import statement.  I rarely have more than one CSS file for a Web site, so I generally use the LINK element (like the one shown below).

    <link rel="stylesheet" type="text/css" href="web.css">

    But if you anticipate using more than one CSS file in a Web site, you can use the @import statement, as shown in the following code:

    <style type="text/css">
    @import url(web.css);
    @import url(page.css);
    </style>

    Dave gives a great explanation of the difference between these two and what happens if two styles conflict with each other.

    It really is that simple.  Deciding which styles to use is much more difficult.  I (personally) like the CSS attribute reference list on MSDN, but keep in mind that some of the CSS attributes listed are IE only (like the scrollbar styles).  Plus, there are literally dozens of online CSS resources.  Here are just a few that I found through the new MSN search.  Try your own search and find your own CSS resources.

  • Customizing IntelliSense

    If you've worked with Code view in FrontPage 2003, you've undoubtedly come to appreciate IntelliSense. But what if you need an element or attribute that isn't included in any of the default HTML schemas? For example, W3C accessibility guidelines include a headers attribute for TD elements. If you frequently use the headers attribute, love hand coding, and are tired of typing "headers" everytime you need to insert this attribute, this tip is for you.

    Background

    FrontPage uses XSDs (XML Schema Definition documents) to provide IntelliSense in Code view.  In fact, this is the same as what Visual Studio uses to provide IntelliSense for HTML and XML schemas, and FrontPage even uses many of the schema annotations that Visual Studio uses.  Schema annotations are contained in the schema definition (i.e., <xsd:schema ... >) listed at the beginning of an XSD.  (For more information, see Visual Studio .NET Schema Annotations.) However, you should note that FrontPage does not use all of these annotations, so be careful using annotations or annotation values other those included in existing FrontPage IntelliSense schemas.

    In addition, FrontPage provides IntelliSense only for HTML (including XHTML), not XML. So if you are inclined to playing with this feature by adding custom elements or using a custom XML schema, you may quickly find that IntelliSense for a selected schema won't function as expected or desired. However, making simple changes to existing HTML schema files (which I show you how to do in the procedure below) allows you to create some custom HTML IntelliSense.

    You should also keep in mind that although changes you make may validate in Visual Studio or another XSD editor, FrontPage may not be able to understand them, which more than likely will break IntelliSense for all documents that use that schema.  Whenever possible, work with the XSD source code (such as in Notepad or XML view in Visual Studio) rather than with a visual XSD designer and make simple changes.

    Note   Breaking IntelliSense does not mean that IntelliSense will not work at all. Rather, IntelliSense won't work for documents that use a specific IntelliSense schema that FrontPage doesn't understand.  IntelliSense will work for other IntelliSense schemas.  Simply select a different schema from the Schema Version option on the Authoring tab of the Page Options dialog box.

    More important things to remember when playing with IntelliSense schemas are

    • always copy the schema file so that you don't overwrite the original schema making it impossible to recover the original schema without reinstalling FrontPage 
    • always change the vs:friendlyname annotation value at the beginning of the XSD so that you can differentiate between existing schemas and your custom schema (this value shows up under Schema Version on the Authoring tab of the Page Options dialog box)
    • don't make too many changes before testing the schema in FrontPage (and always create a backup of your changes XSD before making additional changes in case an additional change breaks Intellisense)
    • never replace an existing schema with a custom schema (just in case a future service pack or update replaces this file, destroying all of your changes)

    Procedure

    Okay, now that you know all the gochas, the following instructions explain how to add the headers attribute to a custom IntelliSense schema.  You can use these basic instructions to create additional IntelliSense schemas for FrontPage.

    1. Close FrontPage.
    2. Open Windows Explorer and navigate to:
      C:\Program Files\Common Files\Microsoft Shared\OFFICE11\SCHEMAS\HTML
      This folder contains the schema and type libraryfiles that FrontPage uses for IntelliSense. All the XSD files are IntelliSense. For example, ie3_2nav3_0.xsd contains IntelliSense for IE 3.2 and Netscape Navigator 3.0.
    3. Copy IE5_0.xsd and change the name of the copied file to IE5_0_Modified.xsd. Copying makes sure that you don't overwrite the original file. DO NOT SKIP THIS STEP.
    4. Open the new file in Notepad.
      Note You can also use Visual Studio or another XSD editor. However, you should note that if you use something other than Notepad, you will need to view the source of the XSD in order to follow the remaining instructions.)
    5. In Notepad, turn off Word Wrap (Format menu). (This makes the schema easier to read and work with.)
    6. In the opening XSD statement, locate vs:friendlyname="Internet Explorer 5.0" and add the word "Modified" to the friendly name so that it reads: vs:friendlyname="Internet Explorer 5.0 Modified"
    7. Search for: name="td"
    8. Scroll down to the list of attributes for the TD element.
    9. Add a new attribute for "headers". For example, add the following text under one of the existing attributes. (I placed it beneath the id attribute, but you can put it beneath any attribute for the TD element as long as you don't add it between the opening and closing tags of the attribute element for another HTML element.)
      <xsd:attribute name="headers" />
    10. Save the file.
    11. Start FrontPage.
    12. From the Tools menu, select Page Options.
    13. On the Authoring tab, under Schema Version (at the bottom of the dialog box), select Internet Explorer 5.0 Modified.

    If you did everything right, when you add a TD element in Code view, you will find the headers attribute listed in the IntelleSense. The IntelliSense feature in FrontPage is very sensitive, so if you don't follow these instructions exactly, it may break Intellisense for your schema. Also, you can't make changes to the XSD while FrontPage is opened (or rather you can, but if you do, Intellisense will not function properly). You need to reboot FrontPage before IntelliSense schema changes take effect.

More Posts Next page »

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker