[Pmwiki-users] RE: Search page focus

Dave Jackson dave.jackson
Sun Oct 26 08:27:43 CST 2003


Hello

This works for IE, and I assume any other browser that supports
VBScript.  (I appreciate that list may not be long :) )

In local.php, place the following, (lifted straight out of search.php,
then added to)

##code start##
SDV($HandleActions['search'],'HandleSearch');
if (isset($EnablePathInfo) && !$EnablePathInfo)
  SDV($SearchTagFmt,"<form action='\$ScriptUrl' method='get'><input
    type='hidden' name='pagename' value='\$PageName'><input
type='hidden'
    name='action' value='search' /><input type='text' name='text'
value=''
    size='40' /><input type='submit' value='$[Search]' /></form><script
language=\"vbscript\">document.all.text.focus</script>");

SDV($SearchTagFmt,"<form action='\$PageUrl' method='get'><input
  type='hidden' name='action' value='search' /><input type='text'
  name='text' value='' size='40' /><input type='submit'
  value='$[Search]' /></form><script
language=\"vbscript\">document.all.text.focus</script>");
##code end##

This adds the bit of client side script to put the focus in the box. 
It works on the edit page and if you have a search box using [[$Search]]
mark-up. I assume this is why I had to do it twice.  I'm no Php coder,
and this looks like advanced coding if ever I saw it. :-) 
More assumptions; SDV is a function in pmWiki.php that expands
variables, I think.  So I assume that the other 'SDV' functions in
search.php will work 'as intended' ?

Perhaps someone knows the best script to make it more browser friendly? 

While I'm on, I also have the following in my local.php:

##code start##
$PageEditFmt = str_replace("</form>",
"<input type='button' value='Cancel'
OnClick='window.location=\"\$PageUrl\";return false;' /> </form><script
language=\"vbscript\">document.all.text.focus</script>",
"$PageEditFmt"); ##code end##
##code end##

This puts the focus in the text box on an edit page, and adds a cancel
button.  Again, I don't know if str_replace is the best way of achieving
this, but hey, works for me.  I can't use the same trick in the code
above, as I get header errors.  Don't know enough yet to say why...

David Jackson 



More information about the pmwiki-users mailing list