开发者

Automatically focus on search box when switching tabs

开发者 https://www.devze.com 2023-02-19 16:24 出处:网络
I\'m editing a start page made by someone else (found here: http://defined04.deviantart.com/art/KMay-Start-Page-184915031?q开发者_Python百科=gallery%3Adefined04%2F790342&qo=0). This lets you switc

I'm editing a start page made by someone else (found here: http://defined04.deviantart.com/art/KMay-Start-Page-184915031?q开发者_Python百科=gallery%3Adefined04%2F790342&qo=0). This lets you switch search engines by clicking on the different tabs. Is there a way to have the search box automatically selected when I select a tab? At the very least, how can I get the default engine to be selected on page load?


On the click handler of your tab, do this....

document.getElementById('tabs-container').getElementsByTagName('li').onclick = function () {

   document.getElementById('search-input-' + this.id).focus();

}

Of course, change it to suit your HTML. Hopefully if you have a tie like that between them, you can write one event handler and not three.


You can use javascript focus() for that. Execute the script when the tab is changed.

0

精彩评论

暂无评论...
验证码 换一张
取 消