Welcome Guest Search | Active Topics | Sign In | Register

Programatically set focus point for Search Options
Des Ward
Posted: Tuesday, July 16, 2024 11:39:59 AM
Rank: Newbie
Groups: Member

Joined: 7/16/2024
Posts: 2
I have a .NET Windows Forms User Control with an EO web browser in one panel, and a list in an other panel, such that when I click on an item in the list it scrolls the html to the element that corresponds to the list item.

This all works nicely, I'm using:
ScriptCall($"document.getElementsByClassName('someclass')[{index}].scrollIntoView();", donehandler);

I've also added searching with StartFindSession in the browser, which generally works fine, but I want to be able to search Next/Previous from the location I've scrolled to. If I manually click anywhere in the browser window then search continues from that point - but I don't want the user to have to click - I need a way of programatically setting the focal point of the search when I do the scroll.

I've tried:
var x = document.getElementsByClassName('someclass')[{index}]; x.scrollIntoView(); x.focus()

Any help gratefully received, Cheers Des :-)
Des Ward
Posted: Wednesday, July 17, 2024 4:51:50 AM
Rank: Newbie
Groups: Member

Joined: 7/16/2024
Posts: 2
Well the cardboard cutout strikes again!
Solved it with a bit more javascript research, specifically here:
stackoverflow

Adding
Code: JavaScript
var selecton = window.getSelection();
selection.setBaseAndExtent(x,0,x,1);


does the job.

Cheers, Des :-)
eo_support
Posted: Wednesday, July 17, 2024 3:51:02 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Great. Thanks for sharing!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.