Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

capturing content of DIV with asp?

Status
Not open for further replies.

spastica

Programmer
Sep 27, 2002
72
0
0
GB
Is there a way to capture the content of a div on a page using ASP? The main content of my website is in a div of it's own, and I would like to create printer freindly pages that print only the content of that div in a new/same window. I know this can be done with Javascript, but it makes Firefox and Netscape hang.

Thanks in advance!
 
Well the HTML source is basically a text file.

I suppose you could parse the file and extract everything between the <div> and </div> ... just like parsing any other text file.
 
You can use the FileSystemObject to do it.

Use its OpenTextFile method to return a TextStream object. Then you can call the ReadAll method on the TextStream to copy the file into a string variable in your script.

Then you just use your scripting languages string manipulation functions to parse the web page as a text file.

If you are using VBScript for example you would use the InStr() function to find the position of your beginning and ending DIV tags and then use the Mid() function to extract that portion of the file into a separate string variable.

Then you could just write the contents of that variable out to the browser response.
 
Can you just use the CSS media tags to hide anything you don't want to print. Have a look here:

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Essex Steam UK for steam enthusiasts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top