Development Tips for Custom Project Guides

Following are seven tips for developers of custom Project Guides, plus seven known issues and work-arounds.

Tips

  1. Put XML data on the same share as the Project Guide pages.

    If the main functionality and layout page, or a side pane HTML page, is located on a network share, then any XML data to which the page needs access must reside on the same share. This includes the Project Guide default content file (gbui.xml), or any other XML data source — including an XML schema — that a custom side pane requires.

    For more information on the reasons why this is so, see Cross-Frame Scripting in Project Guide Security.

  2. Put XML data for an ActiveX control on the same network share.

    If an ActiveX® control that reads XML data is hosted on a network share, the XML data file must be on the same share. The reason is similar to the cross-frame scripting issue for Microsoft® Internet Explorer.

    For example, you could create an ActiveX control to customize the side pane for a particular task. If you put the ActiveX control on a network share, you must also put the side pane XML document that it uses on the same share.

  3. Use the DisplayTaskHeader and DisplayGoalAreaHeader mainpage.htm functions in custom side panes.

    A well-designed side pane calls the DisplayTaskHeader and DisplayGoalAreaHeader functions in mainpage.htm to maintain the current GBUI state and display the side pane header. If the side pane does not call those functions, the state is undefined and the Project Guide displays the default side pane.

    In the following example, newspages.htm must call the mainpage.htm functions to correctly show the News Sites side pane.

    <GoalArea>
       <GoalAreaID>6</GoalAreaID>
       <GoalAreaName>News Sites</GoalAreaName>
       <GoalAreaDescription>All the news that's fit to print.</GoalAreaDescription>
       <URL>http://projweb/gbui/newspages.htm</URL>
    </GoalArea>
    

    In the example, newspages.htm would use the pDisplayGoalAreaHeader function as described in Project Guide Security.

  4. Avoid using Microsoft JScript® code in the HREF parameter of a side pane link. Use the OnClick parameter instead. For example, the following link replaces the side pane with a blank page:

    <A href="javascript:parent.frames.rightFrame.location.href='http://badger.cx'">Badger.cx</A>
    

    The link works correctly when the OnClick link parameter contains the following JScript code:

    <A href="#" onclick="javascript:parent.frames.rightFrame.location.href='http://badger.cx'">Badger.cx</A>
    
  5. Change the OnContextMenu event code to enable a right-click menu.

    The context (right-click) menu in Project Guide pages is disabled by default, because the default Internet Explorer context menu does not work correctly with Microsoft Office Project. All default Project Guide pages include the following onContextMenu attribute with the <BODY> tag to disable the context menu:

    <body onContextMenu="return false">

    You can enable a custom context menu in a whole page, or different menus within any part such as a <DIV> tag, providing you don't display the default Internet Explorer context menu. You can also include context menus in a custom GBUI.xml file with the <CONTEXT_MENU> tag. For an example of how to enable custom context menus, see oncontextmenu Event Sample in the MSDN® Library.

  6. Don't use the innerHTML property in custom side panes.

    For security reasons, we don't recommended that you use the innerHTML property in script for custom side panes. A user could receive a Project document that has a custom Project Guide with executable JScript code in the innerHTML property of a side pane. If the resources are in text files, such as XML, the text could be altered easily with malicious code, and the user would not be aware that the code executes when the side pane is displayed.

    Note  Some of the default Project Guide files, such as more_data_fields.js and more_res_fields.js, use innerHTML. The use is necessary in these cases for localization. There is no simple way to add malicious code in these cases, because the data comes from a resources DLL.

  7. Don't use document.write to dynamically modify text in a frame.

    If you have a page with a top and bottom frame, and you use document.write to dynamically modify the bottom frame text content, for example, the function overwrites all content in the bottom frame. All objects and scripts in the bottom frame are lost after document.write executes. This can cause the Project script engine to fail when it tries to close.

    To dynamically modify text in an HTML block element, you can use the innerText property. For more information, see innerText Property in the MSDN Library.

Known Issues and Work-arounds

  1. Include both server URLs in the Trusted Sites list: Project Server and Windows SharePoint Services.

    If you get an untrusted site notification, make sure both the Microsoft Office Project Server and the Microsoft Windows® SharePoint™ Services server are included in the Trusted Sites list for Internet Explorer. Check the list of sites on the Security tab in the Internet Options dialog box. If the servers running Project Server and Windows SharePoint Services are different, the list should include entries similar to the following:

    http://projectservername
    http://wss_servername
    
  2. Use the OnKeyPressed event, instead of OnKeyUp or OnKeyDown.

    Project Guide scripts do not get OnKeyUp and OnKeyDown events from hosted Web content, including side panes and Microsoft Office Project Web Access pages. If you have script that determines when a side pane button should be disabled or enabled, you can use the OnKeyPressed event.

    Note  Some special keys, such as BACKSPACE, may not generate this event.

  3. Use "straight" quotation marks in XML files, not "smart" quotation marks.

    The Project Guide does not load XML files that contain the left or right double quotation mark ("", which are chr$(147) and chr($148)). Use the straight quotation mark (chr$(34)) instead, as in the following line:

    <?xml version="1.0" encoding="UTF-8"?>

  4. Don't use HTTP-EQUIV="REFRESH" on pages with modal dialog boxes.

    During a page refresh, frame pages are unloaded and the view window goes away even though there still can be a modal dialog box that was opened from the page. The page is unloaded before the BeforeNavigate2 message from the WebBrowser control, so there is no chance to cancel the operation.

    You should not write pages with HTTP-EQUIV="REFRESH" unless you do not use the view control.

  5. Don't place side pane code outside of a function.

    Script code that is placed outside of a function executes when the file is loaded. For example, suppose an HTML file contains the following code:

    <SCRIPT LANGUAGE=vbscript>
    . . .
    window.external.Application.CustomFieldSetFormula 188743767, "[text2] - [text3]"
    . . .
    </SCRIPT>
    

    The page would run an infinite loop, because Project disables XCMDs during navigation and also waits for navigation to be completed when an XCMD is executed. That is, navigation cannot complete until the script is finished, and the script cannot complete until the navigation is finished. To avoid this problem, put statements into functions that get called when they are needed.

  6. Don't use quotation marks in the <ViewName> tag of GBUI.xml.

    For example, the following value of the ViewName element does not work:

    <ViewChange>
       <ViewName>"My Custom View"</ViewName>
       <GoalAreaID>5</GoalAreaID>
    </ViewChange>
    

    Instead, use the following:

    <ViewChange>
       <ViewName>My Custom View</ViewName>
       <GoalAreaID>5</GoalAreaID>
    </ViewChange>
    
  7. Avoid an infinite loop when using a custom GBUI.xml with Internet Explorer 5.0 (only).

    With Microsoft Internet Explorer 5.0, if a custom GBUI.xml file has invalid references, or uses another XML file with invalid references, the Project Guide can get into an infinite loop. For example, if a file contains references to a page to which the user does not have access, the page continuously shows the Use Default - Retry alert. Clicking Use Default has no effect, because that indicates the Project Guide should use the default mainpage.htm, not the default XML file.

    This is not a problem with Internet Explorer 5.5 and 6.0. Versions later than 5.0 are able to load an error side pane instead of showing the alert.