homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

controling focus with php

 9:58 pm on Jul 16, 2007 (gmt 0)

Are there ways to control focus in a .php page withing a php script? I can't find anything in the documentation. I've also tried using JavaScript along with php but that doesn't seem to work.



 5:21 am on Jul 17, 2007 (gmt 0)

You can control focus thru html "z-index"


 6:29 am on Jul 17, 2007 (gmt 0)

What I mean if a method or event similar to JavaScript's focus() ability. When my php pages refresh, nothing is 'onfocus'


 2:21 pm on Jul 17, 2007 (gmt 0)

There's no way of setting focus without javascript, to my knowledge. However, you could have your PHP page echo this near the </body> tag...

<script type="text/javascript">

However, this sort of code must come AFTER "myElementId" on the page (thus why I recommend putting it just before the </body> tag), because otherwise the javascript will load and execute, but will not find "myElementId" because it hasn't been loaded yet.

Alternately, you could find a method of determining when the page has loaded and call a function to focus on the element.

If you use Firefox, I would highly recommend downloading a plugin (not sure if I can name it here) that allows you to debug javascript. If any javascript errors come up, it will show you what the error is and where in the code it comes from--you can also set breakpoints in the JS code and step through it to see where your problem occurs and what the values of nearby variables are. Very handy.

Hope this helps!


 6:40 am on Jul 18, 2007 (gmt 0)

Yeah WesleyC, I think that is the way to do it. I guess I'll use JavaScript to check everything then use php for handling the info.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved