Webflow sync, pageviews & more.
NEW

How can I activate a specific button on the 'Filters' page after clicking a link on the 'Home' page in Webflow?

TL;DR
  • Add a query parameter (e.g., ?category=shoes) to the link on the Home page.
  • On the Filters page, assign matching data attributes (e.g., data-category="shoes") to each button.
  • Use custom JavaScript to read the parameter and trigger a click on the matching button when the page loads.

To activate a specific button on the 'Filters' page after clicking a link on the 'Home' page, you can use URL query parameters combined with custom JavaScript in Webflow.

  • Go to the 'Home' page in Webflow Designer.
  • Select the link or button that will navigate to the 'Filters' page.
  • In the Link Settings, set the link to something like:
    filters?category=shoes
    Replace category=shoes with a key-value pair relevant to what button you want to activate.

2. Assign Data Attributes to Target Buttons on Filters Page

  • Go to the 'Filters' page in Webflow.
  • Select the button you want to be activated when the page loads.
  • In the Element Settings, add a custom attribute like:
  • Name: data-category
  • Value: shoes
  • Do this for each filter button with unique values.

3. Add Custom JavaScript to Activate Button

  • Open the Page Settings for the 'Filters' page.

  • Scroll to the Before tag field.

  • Paste this custom script (adjust selectors as needed):

    ```javascript

    ```

  • This script:

  • Reads the query parameter (e.g., category=shoes)

  • Finds the button with the matching data-category value

  • Triggers a click on that button (or adds an active state)

Summary

Use a query parameter in your link from the 'Home' page and target buttons via data attributes on the 'Filters' page. A small snippet of custom JavaScript detects the parameter and programmatically activates the correct button.

Rate this answer

Other Webflow Questions