How to grab specific string of text from HTML page to display in pop up browser window?

Discussion in 'Javascript' started by Ed, Jul 26, 2004.

  1. Ed

    Ed Guest

    I am building a glossary. Each letter of the alphabet has its own
    HTML page, and each glossary entry on the page already has a unique
    HTML anchor tag immediately to the left of it.

    I've already learned how to do a Javascript pop up browser window. Is
    there a way to create one that will use the existing HTML anchors as
    markers and retrieve and display only the text string that starts
    after a specified anchor, and ends just before then next anchor?

    Ed
     
    Ed, Jul 26, 2004
    #1
    1. Advertising

  2. Ed

    kaeli Guest

    In article <>,
    enlightened us with...
    > I am building a glossary. Each letter of the alphabet has its own
    > HTML page, and each glossary entry on the page already has a unique
    > HTML anchor tag immediately to the left of it.
    >
    > I've already learned how to do a Javascript pop up browser window. Is
    > there a way to create one that will use the existing HTML anchors as
    > markers and retrieve and display only the text string that starts
    > after a specified anchor, and ends just before then next anchor?
    >
    > Ed
    >


    Like this?
    Tested in NN7/IE6. No claims made for other browsers. Watch for word-wrap.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
    "http://www.w3.org/TR/REC-html40/loose.dtd">
    <html>
    <head>
    <title> New Document </title>
    <script type="text/javascript" language="javascript">
    function checkIt(lnk)
    {
    alert(lnk.innerHTML);
    }
    </script>
    </head>

    <body>
    <a href="someLink.html" onClick="checkIt(this);return false;">Text of link
    </a>
    </body>
    </html>

    --
    --
    ~kaeli~
    If a book about failures doesn't sell, is it a success?
    http://www.ipwebdesign.net/wildAtHeart
    http://www.ipwebdesign.net/kaelisSpace
     
    kaeli, Jul 26, 2004
    #2
    1. Advertising

  3. Ed

    Ed Guest

    kaeli <> wrote in message news:<>...
    > In article <>,


    >
    > Like this?
    > Tested in NN7/IE6. No claims made for other browsers. Watch for word-wrap.
    >
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
    > "http://www.w3.org/TR/REC-html40/loose.dtd">
    > <html>
    > <head>
    > <title> New Document </title>
    > <script type="text/javascript" language="javascript">
    > function checkIt(lnk)
    > {
    > alert(lnk.innerHTML);
    > }
    > </script>
    > </head>
    >
    > <body>
    > <a href="someLink.html" false;">Text of link
    > </a>
    > </body>
    > </html>
    >

    Kaeli,

    Thanks for you fast response. When I tried this, it popped up a grey
    alert box that contained the link description text ("Text of link" in
    your example), but nothing from the page that I linked to
    (someLink.html" in your example). Was that what it was supposed to
    do?

    What I was after was to open up a small new browser window which
    contained only the text between two anchors on another page, e.g. the
    link resides on page_one.html, and when clicked it pops up a small
    browser window which contains only the text found between
    page_two.html#firstanchor and page_two.html#secondanchor.

    Any ideas?

    Ed
     
    Ed, Jul 29, 2004
    #3
  4. Ed

    kaeli Guest

    In article <>,
    enlightened us with...
    > kaeli <> wrote in message news:<>...
    >
    > Thanks for you fast response. When I tried this, it popped up a grey
    > alert box that contained the link description text ("Text of link" in
    > your example), but nothing from the page that I linked to
    > (someLink.html" in your example). Was that what it was supposed to
    > do?


    Yes.

    >
    > What I was after was to open up a small new browser window which
    > contained only the text between two anchors on another page, e.g. the
    > link resides on page_one.html, and when clicked it pops up a small
    > browser window which contains only the text found between
    > page_two.html#firstanchor and page_two.html#secondanchor.


    Sorry, I misunderstood what you wanted.
    I've been putzing around with using an IFRAME, but so far haven't gotten it
    to work well in IE (issue with waiting for the contents to load and catching
    that event before trying to read the contents) or work at all in NN6 (won't
    let me reference the iframe with document.frames and won't let me access the
    iframe document contents with getElementById).

    I'd do this server-side, to be honest. Anything you do client-side is going
    to be a JS hack to read and parse the contents of the file and won't be as
    cross-browser as an internet app should be.

    --
    --
    ~kaeli~
    Do not taunt Happy Fun Ball!
    http://www.ipwebdesign.net/wildAtHeart
    http://www.ipwebdesign.net/kaelisSpace
     
    kaeli, Jul 29, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    8,605
    Randy Webb
    Feb 4, 2006
  2. Shiperton Henethe
    Replies:
    17
    Views:
    5,500
    Deirdre Saoirse Moen
    May 21, 2004
  3. Madame Blablavatsky
    Replies:
    8
    Views:
    207
    Dr John Stockton
    Sep 16, 2005
  4. Replies:
    2
    Views:
    158
    Randy Webb
    Feb 4, 2006
  5. Jimmy
    Replies:
    3
    Views:
    185
    David Mark
    Oct 7, 2007
Loading...

Share This Page