PDA

View Full Version : Need help with a simple JS



mantalcore
08-07-2006, 04:55 PM
Hi, for my work, I need to create a script that can read the HTML between these 2 tags:

<!-- Begin Main Content Area -->

and

<!-- End Main Content Area -->

I usually program in java for most of the stuff I do but this time, I don't know how to have Java read in all the lines in between, and then create a popup window and display all the read information. This way, it makes a printer friendly page without the navigation and etc.

If anyone could help me that would be greatly appreciated.

mantalcore@yahoo.com
AIM: whatthextothez

blm126
08-07-2006, 05:09 PM
This would not be very difficult if we could see the page(or code of the page) in question.

Twey
08-07-2006, 05:27 PM
You're really better off doing this server-side. Stick to Java: write a JSP or a servlet.

mburt
08-07-2006, 05:28 PM
Using "<!--" and "-->" are lines the make html code invisible to the browser. There is no way (that I'm aware of) to read this.

mburt
08-07-2006, 05:32 PM
Oooh.. I figured out something:


onload=function() {
var body=document.body.innerHTML
var innercode=body.substring(body.indexOf("||")+2,body.indexOf("end||"))
document.write(innercode)
}


Right your statements like this:



<!--||

end||-->


any html code inside that can be read :)

Twey
08-07-2006, 05:33 PM
You should probably have a .toString() in there somewhere.