Results 1 to 1 of 1

Thread: [JavaScript] Focusing Form Element

Threaded View

  1. #1

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765

    Resolved [JavaScript] Focusing Form Element

    Hmmm, not sure whats going atm..

    I have a page with an Iframe, and inside that Iframe is a text box. When the Iframe loads, I call a function in the mainpage that sets focus to the Textbox (since that way it will try to set focus when the page has loaded?).

    I call the function using,
    parent.SetSendMessageFocus();

    And the function is,

    Code:
    	function SetSendMessageFocus() {
    		document.getElementById('sendmessage').contentDocument.frmSend.message.focus();
    	}
        setTimeout(SetSendMessageFocus , 100 );
    Apparently you need to use SetTimeOut to get focus to work properly (and it wasn't working before I added it), but now it works when everything loads for the first time, and after that it just doesn't set focus anymore.

    Edit:
    Ok, it appears theres something dodgy with this other piece of Javascript I have working onLoad, or perhaps I just write really dodgy PHP... Hmm! Yeah this thread can be deleted if you wishes.
    Last edited by Pc_Madness; Jun 27th, 2005 at 08:47 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width