Results 1 to 6 of 6

Thread: Need help with a simple JS

  1. #1
    Join Date
    Aug 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Need help with a simple JS

    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

  2. #2
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    This would not be very difficult if we could see the page(or code of the page) in question.

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You're really better off doing this server-side. Stick to Java: write a JSP or a servlet.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Using "<!--" and "-->" are lines the make html code invisible to the browser. There is no way (that I'm aware of) to read this.
    - Mike

  5. #5
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Oooh.. I figured out something:

    Code:
    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:

    Code:
    <!--||
    
    end||-->
    any html code inside that can be read
    - Mike

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You should probably have a .toString() in there somewhere.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •