![]() |
Cursor starting in Search form?
When an X-Cart page is loaded, I want the cursor to automatically appear in the Search box. In search.tpl (skin1/customer/), I tried adding
tabindex="0" or tabindex="1" to the text input form code, but it doesn't help. The first "tab" I hit highlights the URL in the address bar (this is in IE7), the 2nd the Refresh button, 3rd browser Google search field, 4th-7th other browser buttons, finally the 8th tab shows a cursor in the Search field. Many other web sites I use open a new page with the cursor in either their Login field or their Search field. Anybody solved this problem? Thanks, Dan |
Re: Cursor starting in Search form?
In skin1/customer/home.tpl
Add this to your <body> tag Code:
onLoad="document.getElementById('posted_data[substring]').focus()" :) |
Re: Cursor starting in Search form?
That works! Really excellent - thanks.
--Daniel |
Re: Cursor starting in Search form?
This solution works in IE7, but not so much in Firefox 1.5.0.8.
With the search.tpl input form code using tabindex="1", a new page in FF requires one hit of the "Tab" key, to get the cursor to the Search box. Set to tabindex="0", it requires 8 hits. In IE7, either tabindex setting works - new pages load with the cursor already there. |
Re: Cursor starting in Search form?
I found something that works in both FF and IE, and no "error on page" msgs. It sets an ID for both the search form and the text box. For example:
In search.tpl: Code:
<form method="get" action="search.php" name="search" id="formid"> Code:
<body onload="document.forms.formid.textboxid.focus()"> |
All times are GMT -8. The time now is 12:01 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.