We all met the "View Source" functionality in browsers. You just right click the page, and click on "View Source"; Notepad (most probably) will launch up and display the page markup. If you are using a server side technology like ASP.NET, you will only get the HTML markup that renders the page in the browser. You will not be able to see any source code even if it is in-lined.
What if you want to read the HTML markup to a variable in your script? e.g. let's imagine that you have this complicated custom list. Users will need to read a small write up before they start using it. On your first visit, the list should be hidden and the write up will be displayed. Once you create your first item, the write up will disappear. The write up will not be displayed in any future visits. (Sorry had to add the MOSS flavor )
Approaching a solution is simple:
To use the XML HTTP Request to parse a remote page, we go through 2 steps:
The entire page markup now is loaded into the variable "htmlmarkup". Now we need to search for the user name in the string, but we have one problem left: we have no clue about the current logged in user.
In order to sort this we use WinNetwork:
Let's search for any created documents that belong to the logged in user, if we find any then we hide the div that contains the small write up.
If no matches found, the function will return "-1". The div name is "SmallWriteUp". We use the "getElementById" method under "document" in HTML DOM to set the visibility property of the div to hidden.