How get windows FIND() to work?...

R

Robert Baer

Guest
Environment: Win7.1 Firefox 78

Sample line used:
<a href=\"downhole-measurements.html?find=able\">Downhole Measurements</a>

At least execution transfers from the calling HTML to the desired
destination HTML.

BUT. the keyword does NOT get underlined or highlighted in any way.
It would be particularly nice if all the keywords got highlighted
and the first keyword was presented on the screen (think loong document
and keyword was in middle).

Help?
 
Robert Baer:

Environment: Win7.1 Firefox 78

Sample line used:
a href=\"downhole-measurements.html?find=able\">Downhole Measurements</a

At least execution transfers from the calling HTML to the desired
destination HTML.

BUT. the keyword does NOT get underlined or highlighted in any way.

If course not. Why should adding \"?find=able\" do that?

Technically calling \"downhole-measurements.html?find=able\" will just
open the document referred by \"downhole-measurements.html\" and pass the
querystring \"find=able\" to the server.

If the document was opened locally as file and not via HTTP then adding
\"?find=able\" does nothing at all.

It would be particularly nice if all the keywords got highlighted
and the first keyword was presented on the screen (think loong document
and keyword was in middle).

Then you need to build some server side script which reads the document
and *adds* elements to highlight the places where the searched text was
found. For example if you use PHP on the server the URL could be:

find.php?document=downhole-measurements.html&text=able

Then the script \"find.php\" will get the paramters \"document\" and \"text\",
where \"document\" tells it which file to read and \"text\" which text to
search for.

--
Arno Welzel
https://arnowelzel.de
 
On 4/8/20 12:13 pm, Robert Baer wrote:
  Environment: Win7.1 Firefox 78

   Sample line used:
a href=\"downhole-measurements.html?find=able\">Downhole Measurements</a

   At least execution transfers from the calling HTML to the desired
destination HTML.

   BUT. the keyword does NOT get underlined or highlighted in any way.
   It would be particularly nice if all the keywords got highlighted
and the first keyword was presented on the screen (think loong document
and keyword was in middle).

You won\'t get highlighting without adding Javascript.

I suggest you use a fragment identifier:

<a href=\"downhole-measurements.html#able\">Downhole Measurements</a>

because that gets passed to the browser, which will scroll to the
matching <a name=\"able\"> tag. The fragment string is also available to
Javascript by using

var fragment = location.hash; // Returns \'#able\'

You could use that to highlight the appropriate text.

Clifford Heath.
 
Robert,

Sample line used:
a href=\"downhole-measurements.html?find=able\">Downhole Measurements< /a

I think you are looking for

< a href=\"downhole-measurements.html#able\">Downhole Measurements< /a>

with in that \"downhole-measurements.html\" document the following line just
above the \"able\" chapter

< a name=\"able\">

(remove the spaces after the \"<\" symbols)

Regards,
Rudy Wieser
 
Clifford Heath wrote:
On 4/8/20 12:13 pm, Robert Baer wrote:
   Environment: Win7.1 Firefox 78

    Sample line used:
a href=\"downhole-measurements.html?find=able\">Downhole Measurements</a

    At least execution transfers from the calling HTML to the desired
destination HTML.

    BUT. the keyword does NOT get underlined or highlighted in any way.
    It would be particularly nice if all the keywords got highlighted
and the first keyword was presented on the screen (think loong
document and keyword was in middle).

You won\'t get highlighting without adding Javascript.

I suggest you use a fragment identifier:

a href=\"downhole-measurements.html#able\">Downhole Measurements</a

because that gets passed to the browser, which will scroll to the
matching <a name=\"able\"> tag. The fragment string is also available to
Javascript by using

var fragment = location.hash; // Returns \'#able\'

You could use that to highlight the appropriate text.

Clifford Heath.
Does not that require EVERY instance of \"able\" in every document to
be tagged?
Or at minimum, the first instance to be tagged?

MUCH easier and saner to (somehow) get the browser FIND() to do its
thing; even IE8 dew that.

Thanks
 
Robert Baer:

Clifford Heath wrote:
On 4/8/20 12:13 pm, Robert Baer wrote:
   Environment: Win7.1 Firefox 78

    Sample line used:
a href=\"downhole-measurements.html?find=able\">Downhole Measurements</a

    At least execution transfers from the calling HTML to the desired
destination HTML.

    BUT. the keyword does NOT get underlined or highlighted in any way.
    It would be particularly nice if all the keywords got highlighted
and the first keyword was presented on the screen (think loong
document and keyword was in middle).

You won\'t get highlighting without adding Javascript.

I suggest you use a fragment identifier:

a href=\"downhole-measurements.html#able\">Downhole Measurements</a

because that gets passed to the browser, which will scroll to the
matching <a name=\"able\"> tag. The fragment string is also available to
Javascript by using

var fragment = location.hash; // Returns \'#able\'

You could use that to highlight the appropriate text.

Clifford Heath.
Does not that require EVERY instance of \"able\" in every document to
be tagged?
Or at minimum, the first instance to be tagged?

No.

You still need to write *code* to do this.

MUCH easier and saner to (somehow) get the browser FIND() to do its
thing; even IE8 dew that.

Then do it. What did you try so far? What\'s your problem with it?



--
Arno Welzel
https://arnowelzel.de
 
\"R.Wieser\" <address@not.available> wrote on 04 Aug 2020 in
comp.lang.javascript:

Robert,

Sample line used:
a href=\"downhole-measurements.html?find=able\">Downhole Measurements
/a

I think you are looking for

a href=\"downhole-measurements.html#able\">Downhole Measurements< /a

with in that \"downhole-measurements.html\" document the following line just
above the \"able\" chapter

a name=\"able\"

(remove the spaces after the \"<\" symbols)

Regards,
Rudy Wieser

Google Chrome 84 and up, desktop and mobile,
let you highlight \"This text\" from the url-string:

https://example.org/page.html#:~:text=This%20text




--
Evertjan.
The Netherlands.
(Please change the x\'es to dots in my emailaddress)
 
Arno Welzel wrote:
Robert Baer:

Environment: Win7.1 Firefox 78

Sample line used:
a href=\"downhole-measurements.html?find=able\">Downhole Measurements</a

At least execution transfers from the calling HTML to the desired
destination HTML.

BUT. the keyword does NOT get underlined or highlighted in any way.

If course not. Why should adding \"?find=able\" do that?

Technically calling \"downhole-measurements.html?find=able\" will just
open the document referred by \"downhole-measurements.html\" and pass the
querystring \"find=able\" to the server.

If the document was opened locally as file and not via HTTP then adding
\"?find=able\" does nothing at all.

It would be particularly nice if all the keywords got highlighted
and the first keyword was presented on the screen (think loong document
and keyword was in middle).

Then you need to build some server side script which reads the document
and *adds* elements to highlight the places where the searched text was
found. For example if you use PHP on the server the URL could be:

find.php?document=downhole-measurements.html&text=able

Then the script \"find.php\" will get the paramters \"document\" and \"text\",
where \"document\" tells it which file to read and \"text\" which text to
search for.
Sounds like that approach requires me to edit a few thousand FINDs at
minimum.
What added fuss is required for the document?

Also, what does this find.php script look like?

Thamks
 
Clifford Heath wrote:
On 4/8/20 12:13 pm, Robert Baer wrote:
   Environment: Win7.1 Firefox 78

    Sample line used:
a href=\"downhole-measurements.html?find=able\">Downhole Measurements</a

    At least execution transfers from the calling HTML to the desired
destination HTML.

    BUT. the keyword does NOT get underlined or highlighted in any way.
    It would be particularly nice if all the keywords got highlighted
and the first keyword was presented on the screen (think loong
document and keyword was in middle).

You won\'t get highlighting without adding Javascript.

I suggest you use a fragment identifier:

a href=\"downhole-measurements.html#able\">Downhole Measurements</a

because that gets passed to the browser, which will scroll to the
matching <a name=\"able\"> tag. The fragment string is also available to
Javascript by using

var fragment = location.hash; // Returns \'#able\'

You could use that to highlight the appropriate text.

Clifford Heath.
You mean \"without adding Javascript\" refers to the document.
Adding matching <a name=\"able\"> tags all over the document is not
sane; there are thousands of words needed to be found/highlighted.

Better to get the browser to do its thing; even IE8 does a nice
brwser FIND().


Thanks
 
Evertjan. wrote:
\"R.Wieser\" <address@not.available> wrote on 04 Aug 2020 in
comp.lang.javascript:

Robert,

Sample line used:
a href=\"downhole-measurements.html?find=able\">Downhole Measurements
/a

I think you are looking for

a href=\"downhole-measurements.html#able\">Downhole Measurements< /a

with in that \"downhole-measurements.html\" document the following line just
above the \"able\" chapter

a name=\"able\"

(remove the spaces after the \"<\" symbols)

Regards,
Rudy Wieser

Google Chrome 84 and up, desktop and mobile,
let you highlight \"This text\" from the url-string:

https://example.org/page.html#:~:text=This%20text
Even IE8 FIND() works; highlights all found keywords dynamically,
allows previous/next.
Seems most browsers support this rather well.

Thanks
 
Robert Baer:

Arno Welzel wrote:
Robert Baer:

Environment: Win7.1 Firefox 78

Sample line used:
a href=\"downhole-measurements.html?find=able\">Downhole Measurements</a

At least execution transfers from the calling HTML to the desired
destination HTML.

BUT. the keyword does NOT get underlined or highlighted in any way.

If course not. Why should adding \"?find=able\" do that?

Technically calling \"downhole-measurements.html?find=able\" will just
open the document referred by \"downhole-measurements.html\" and pass the
querystring \"find=able\" to the server.

If the document was opened locally as file and not via HTTP then adding
\"?find=able\" does nothing at all.

It would be particularly nice if all the keywords got highlighted
and the first keyword was presented on the screen (think loong document
and keyword was in middle).

Then you need to build some server side script which reads the document
and *adds* elements to highlight the places where the searched text was
found. For example if you use PHP on the server the URL could be:

find.php?document=downhole-measurements.html&text=able

Then the script \"find.php\" will get the paramters \"document\" and \"text\",
where \"document\" tells it which file to read and \"text\" which text to
search for.

Sounds like that approach requires me to edit a few thousand FINDs at
minimum.
What added fuss is required for the document?

Also, what does this find.php script look like?

It will open the file, read the content, does a strpos() on the search
term and add <span class=\"found\">...</span> around the found word. You
may also need to add the \"found\" CSS rule like this:

..found {
background-color: #ff0;
}

If you want to keep the URL \"downhole-measurements.html?find=able\" you
can also do this with a script in the document itself which takes the
URL (window.location.href), extracts the \"find\" parameter and calls
either window.find() or walks the DOM tree to add a <span
class=\"found\">...</span> around the search hits - but in any case you
need *code* to do the finding. There is no solution which just works by
adding something to the URL.

--
Arno Welzel
https://arnowelzel.de
 
Robert Baer:

[...]
Even IE8 FIND() works; highlights all found keywords dynamically,
allows previous/next.
Seems most browsers support this rather well.

So - why did you even ask in the first place when you already know the
solution?


--
Arno Welzel
https://arnowelzel.de
 
[Stop amok-crossposting. This has nothing to do with computers in general
or electronics design. *facepalm*]

Robert Baer wrote:

Environment: Win7.1 Firefox 78

Sample line used:
a href=\"downhole-measurements.html?find=able\">Downhole Measurements</a

What is happening then depends on the user agent. It is NOT a general
command to highlight something. HTML is NOT a programming language.

The FIND command of CMD.exe has *nothing to do* with HTML/JavaScript.
JavaScript is *case-sensitive*. And “window” is NOT “windows”.

At least execution transfers from the calling HTML to the desired
destination HTML.

HTML is _NOT_ a programming language. HTML does NOT “execute” and does NOT
“call”.

> BUT. the keyword does NOT get underlined or highlighted in any way.

Of course not. HTML – HyperText *Markup* Language – is _NOT_ a programming
language. To highlight something *in general*, you need a *programming*
language.

It would be particularly nice if all the keywords got highlighted
and the first keyword was presented on the screen (think loong document
and keyword was in middle).

Help?

-- downhole-measurements.html -----------------------------------

<!DOCTYPE html>
<html>
<head>
<!-- … -->
<script src=\'highlight.js\'></script>
<!-- … -->
</head>

<body onload=\'highlight.highlightAndFocus()\'>
<!-- … -->
</body>
</html>

-- highlight.js ----------------------------------------------------------

/**
* highlight.js – Highlights occurrences of text in HTML documents
* @author (C) 2020 Thomas \'PointedEars\' Lahn <js@PointedEars.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License at <http://www.gnu.org/licenses/>
* for more details.
*/

var highlight = {
getNeedle: function () {
/* Get value of value of “find” parameter */
var value = (window.location.search.match(/[?&]find=([^&#]+)/) || [,])
[1];
if (value) value = decodeURIComponent(value);
return value;
},

focus: function (needle) {
if (needle)
{
/* Focus first occurence */
if (typeof window.find != \'undefined\' && !window.find(needle))
{
if (typeof console != \'undefined\'
&& typeof console.log != \'undefined\')
{
console.log(\'Text not found: \"\' + needle + \'\"\');
}
}
}
},

highlight: function (needle) {
if (needle)
{
/* Highlight all occurrences */
document.body.innerHTML = document.body.innerHTML.replace(
new RegExp(
/* slurp textareas and tags */
\'(<textarea>(?:[^<]|<[^\\/])+<\\/textarea>|<[^>]+>)|\'
+ needle.replace(/[\\]\\\\^$*+?.(){}|[]/g, \"\\\\$&\"),
\'gi\'),
function (match, tag, offset, all) {
/* ignore elements/tags */
if (tag) return tag;

return (\'<span style=\"background-color: yellow; color: black\">\'
+ match + \'</span>\');
}
);
}
},

highlightAndFocus: function (needle) {
if (!needle) needle = this.getNeedle();
this.highlight(needle);
this.focus(needle);
}
};

--8<----------------------------------------------------------------------

F’up2 comp.lang.javascript

--
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.
 
Evertjan,

Google Chrome 84 and up, desktop and mobile,
let you highlight \"This text\" from the url-string:

https://example.org/page.html#:~:text=This%20text

Thats the first time I\'ve ever heard of it. Thanks.

Regards,
Rudy Wieser
 
On 5/8/20 1:13 pm, Robert Baer wrote:
Clifford Heath wrote:
On 4/8/20 12:13 pm, Robert Baer wrote:
   Environment: Win7.1 Firefox 78

    Sample line used:
a href=\"downhole-measurements.html?find=able\">Downhole Measurements</a

    At least execution transfers from the calling HTML to the desired
destination HTML.

    BUT. the keyword does NOT get underlined or highlighted in any way.
    It would be particularly nice if all the keywords got highlighted
and the first keyword was presented on the screen (think loong
document and keyword was in middle).

You won\'t get highlighting without adding Javascript.

I suggest you use a fragment identifier:

a href=\"downhole-measurements.html#able\">Downhole Measurements</a

because that gets passed to the browser, which will scroll to the
matching <a name=\"able\"> tag. The fragment string is also available to
Javascript by using

var fragment = location.hash; // Returns \'#able\'

You could use that to highlight the appropriate text.

Clifford Heath.
  You mean \"without adding Javascript\" refers to the document.
  Adding matching <a name=\"able\"> tags all over the document is not
sane; there are thousands of words needed to be found/highlighted.

  Better to get the browser to do its thing; even IE8 does a nice
brwser FIND().

I know of no standard way that find-in-page behaviour can be automated.

CH
 
Clifford Heath:

On 5/8/20 1:13 pm, Robert Baer wrote:
[...]
  Better to get the browser to do its thing; even IE8 does a nice
brwser FIND().

I know of no standard way that find-in-page behaviour can be automated.

That was already mentioned:
<https://developer.mozilla.org/en-US/docs/Web/API/Window/find>


--
Arno Welzel
https://arnowelzel.de
 
On 5/8/20 9:54 pm, Arno Welzel wrote:
Clifford Heath:

On 5/8/20 1:13 pm, Robert Baer wrote:
[...]
  Better to get the browser to do its thing; even IE8 does a nice
brwser FIND().

I know of no standard way that find-in-page behaviour can be automated.

That was already mentioned:
https://developer.mozilla.org/en-US/docs/Web/API/Window/find

What part of \"no standard way\" is difficult to understand?
 
Clifford Heath:

On 5/8/20 9:54 pm, Arno Welzel wrote:
Clifford Heath:

On 5/8/20 1:13 pm, Robert Baer wrote:
[...]
  Better to get the browser to do its thing; even IE8 does a nice
brwser FIND().

I know of no standard way that find-in-page behaviour can be automated.

That was already mentioned:
https://developer.mozilla.org/en-US/docs/Web/API/Window/find

What part of \"no standard way\" is difficult to understand?

Did I claim, that this is standard?


--
Arno Welzel
https://arnowelzel.de
 
\"R.Wieser\" <address@not.available> wrote on 05 Aug 2020 in
comp.lang.javascript:

Evertjan,

Google Chrome 84 and up, desktop and mobile,
let you highlight \"This text\" from the url-string:

https://example.org/page.html#:~:text=This%20text

Thats the first time I\'ve ever heard of it. Thanks.

There has to be a first time for everything. Haha.

--
Evertjan.
The Netherlands.
(Please change the x\'es to dots in my emailaddress)
 
On 5/8/20 7:46 am, Evertjan. wrote:
\"R.Wieser\" <address@not.available> wrote on 04 Aug 2020 in
comp.lang.javascript:

Robert,

Sample line used:
a href=\"downhole-measurements.html?find=able\">Downhole Measurements
/a

I think you are looking for

a href=\"downhole-measurements.html#able\">Downhole Measurements< /a

with in that \"downhole-measurements.html\" document the following line just
above the \"able\" chapter

a name=\"able\"

(remove the spaces after the \"<\" symbols)

Regards,
Rudy Wieser

Google Chrome 84 and up, desktop and mobile,
let you highlight \"This text\" from the url-string:

https://example.org/page.html#:~:text=This%20text

Not Chrome \"Version 84.0.4147.89 (Official Build) (64-bit)\" for OS/X.

Where is this feature documented, please?

CH
 

Welcome to EDABoard.com

Sponsor

Back
Top