Accessing Framesets with Microsoft Visual Basic
|SharePoint Designer Developer Reference|
Frames are an important part of the design of a Web site. Microsoft Office SharePoint Designer provides support for programming the content of frames. Click one of the following links for more information on a particular topic.
Role of a frameset
Accessing HTML tags
Dynamic frame sources
Iterating all frames in a page window
Changing Meta tag content to another character set
Accessing frames within a frameset in Office SharePoint Designer is relatively straightforward as long as you keep in mind that each frame accesses its own page and that you access the contents of each page through the Page object model. The two windows involved in displaying the frames are the PageWindow object and DesignerWindow objects. The equivalent expression for accessing the contents in the window associated with the active frame is shown in the following code.
You may get "permission denied" errors if you try to access objects while in HTML view. To eliminate these errors when you want to add code or text to a document object, you can set the ViewMode property to PageViewNormal.
A frameset is the container for all of the frames in a Web window. Each frame is contained in an individual page window and has an individual page associated with it. You can use the FrameWindow property to access the DesignerWindow object that contains the frame page document. From this object you can access the windows, documents, and frames of the frameset. In the following statement,
is a DesignerWindow object that returns the window that contains the frames page document. From this object, you can access the <FRAME> and <FRAMESET> tags, or the window and document objects.
This statement returns a DesignerWindow object, which is equivalent to accessing the frames page using the HTML tab in the page window.
You can access the same information that a frames tag accesses by declaring an object as a FrameElement object. Some of the properties and methods available for this object include border, borderColor, click, frameBorder, frameSpacing, innerHTML, innerText, insertAdjacentHTML, and insertAdjacentText.
You can access the information for a frameset tag by declaring a FrameSetSiteElement object.
You can dynamically change the frame source in the HTML code by using the following statements. This code sets the frame source to a new URL, Inventory_1stQuarter.htm.
To access the properties of the frameset elements that reside in a particular frames page, you must access the DesignerDocument object through the Document property. The following example iterates through the frameset and frame elements for the active frameset in Office SharePoint Designer. The frameset array (myFSElements) comprises each <FRAMESET> tag on the frames page. The frames array (myFramesElements) comprises each <FRAME> tag on the frames page. The frame windows array (myFramesWindows) comprises each DesignerWindow object that points to each frame. You populate each of the arrays by iterating through their respective tags or objects. When the arrays are populated, you change the frameSpacing property in the frameset element to "10", change the borderColor property to "red", and change various other properties in the document.
You can change all of the content-type META tags to a different character set (Central European) as shown in the following code sample. The current character set is shown in the Language Settings dialog box (available for page properties).
|The entire content-type META tag contains a string similar to the following:|
The character set is "windows-1252" and is the default character set for U.S. English.
Each time the program iterates through the loop, you access the next frame in the FrameWindow property, which is the same as accessing each HTML frames tag in succession. However, the Frames collection does not support the For...each statement. You cannot access an HTTP-EQUIV type META tags via its name; you must instead use an index as shown in the following example. The expression beginning with
objContentType.Content sets the character set to Central European.
|By default, Office SharePoint Designer places the content type within the <META> tag zero (0).|