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

E

Ed

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
 
K

kaeli

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>

--
 
E

Ed

kaeli said:
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
 
K

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?
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.

--
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top