Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

166
Views
ElectronJS findInPage find next result and highlight it

I have electron app (^19.0.1) that opens website via url in BrowserWindow. I need to create text search functionality like standard Chrome searchbar.

введите сюда описание изображения

At this moment i can find and mark searchable text via webContents.findInPage, but i couldn't jump to next result, what i'm doing wrong?

My main.js:

win.webContents.on('found-in-page', (event, result) => {
    console.log(result)
});


ipcMain.on('search-text', (event, arg) => {
    let nextRes = arg.direction == 'next' ? true : false
    const requestId = win.webContents.findInPage(arg.searchText, {
        forward: true,
        findNext: nextRes,
        matchCase: false
    });
});

ipcMain.on('stop-search', (event, arg) => {
    win.webContents.stopFindInPage('clearSelection');
});

My preload.js:

const { contextBridge, ipcRenderer } = require('electron')

contextBridge.exposeInMainWorld('electronAPI', {
    searchText: (searchText, direction) => ipcRenderer.send('search-text', { searchText, direction }),
    stopSearch: () => ipcRenderer.send('stop-search')
})

function search(direction) {
    let searched = document.getElementById("searchInput").value.trim();
    if(searched.length > 0){
        window.electronAPI.searchText(searched,direction)
    }                
    document.getElementById("searchInput").focus()
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!