Focus On Input After Clicking Anchor
If you want to see for yourself what I have you can login at http://www.mywebpromo.com with Username: Test and Password: test1234
Once logged in you will see in the top right under the main navigation there are two links "Members" and "Search". When you click search you will see the popup that contains the search box. I want to focus to be on the textbox so that the user can start typing after they click the search link.
First of all you need to add jQuery to your page. http://jquery.com/download/
Secondly, use $("selector").focus();
You will need to substitute the element IDs for what you have on your page.
My site already uses MooTools. Wont jQuery cause conflicts?
You can just use the HTML autofocus attribute.
Depending on the browser, the placeholder text will still remain visible but the cursor will be in the box, such as for Chrome. Other browsers, such as IE 10 will place the cursor in the box but the placeholder text won't be visible. In either case, you can begin typing right away.
<div id = "inputBox">
<form action = "something" method = "post">
<label for = "searcher">Click here to get into the box
<input id = "searcher" type = "text" name = "searchBox" placeholder = "Search something" autofocus />
<input type = "submit" value = "Search!" />
What would I used in the "href" area of the anchor tag?
Originally Posted by Error404
Originally Posted by MatteoMWP
The href would contain the path to your pop-up file. rel = external and the bit of jQuery is the modern equivalent to specifying target = _blank in your anchor tag, which tells your browser to open a new window. In my previous post, I assumed that if your pop-up was taking user input, then you'd want a form to process it but if you're not, then just get rid of the <form> and <input type = "submit" ... /> elements.
<!-- somewhere in the body -->
<a href = "thepopup" rel = "external">Click to open the pop up</a>
$('a[rel = "external]').attr('target', '_blank');
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)