WordPress.org

Ready to get started?Download WordPress

Forums

Boot Store
X Webkit Speech Custom CSS code (5 posts)

  1. Make Ova Fashions
    Member
    Posted 4 months ago #

    Hi

    I found this cool code to add voice search to my site by adding this line of code to my theme searchform.php

    ..." x-webkit-speech speech onwebkitspeechchange="this.form.submit();" />

    How can I add this to the Custom CSS section so that when I update my theme I won't loose the changes I made to that file.

  2. odedta
    Member
    Posted 4 months ago #

    onwebkitspeechchange="this.form.submit();"

    Is a Javascript event, not CSS. You need to update your JS file:

    1. Grab search box via class or id.
    2. Add event handler: onwebkitspeechchange
    3. On firing event: this.form.submit();

    As for your question, unfortunately I do not know where is a "safe" place to store JS code that would not be overwritten on next update.

    What you can do is create a JS file with all your JS code and just link to it in the header simply using:
    <script src="myscripts.js"></script>

    On next update just remember to check that line is still there.

  3. Make Ova Fashions
    Member
    Posted 4 months ago #

    Thanks for the idea, this stuff is a bit above me. I know what you talking about I just don't know exactly how to apply what you've said. I lost you by Grab search box via class or id. I think I will have to go read some JS stuff to understand it better.

    I think I'll just keep that code and make sure it's in the searchform.php the next time I update my theme.

    Thanks again anyways.

  4. odedta
    Member
    Posted 4 months ago #

    Well, in searchform.php

    change:

    <input class="market-search" type="text" placeholder="<?php _e( 'Search', 'bre-bootstrap-ecommerce' ); ?>" name="s" id="s">

    to this:

    <input class="market-search" type="text" placeholder="<?php _e( 'Search', 'bre-bootstrap-ecommerce' ); ?>" name="s" id="s" onwebkitspeechchange="this.form.submit();">

  5. Make Ova Fashions
    Member
    Posted 4 months ago #

    I see that makes more sense. thanks for all your help

Reply

You must log in to post.

About this Theme

About this Topic

Tags

No tags yet.