SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard WorldNews's Avatar
    Join Date
    Nov 2007
    Posts
    1,033
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    How do I move the focus inside a Php generated page?

    Hi,


    How does one move the focus within a Web page, to various DIV elements of that page, which Web page is of course generated by Php?

    So for example if user types A and clicks Submit, I want in the resulting page generated as a result of their POST for them to be at the element on the Web page designated by <div id ="a_elem">

    And if I need to use another idea to achieve the focus result, please advise that. But please keep in mind that the simple <a name="a_elem"></a> since this is a POST generated page.

    ThanX,

    Anoox search engine volunteer

    www.anoox.com

  2. #2
    SitePoint Member
    Join Date
    Nov 2009
    Location
    North Carolina
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile

    Look at this example:

    Code:
    <html>
    <script language="javascript">
    function MovePage()
    {
    	alert('moving page');
    	//location.replace=document.location.href+"#footer";
    	document.location.href=document.location.href+"#footer";
    }
    </script>
    <body onLoad="MovePage();">
    Top of page
    <hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>
    <hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>
    <hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>
    <hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>
    <hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>
    <hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>
    <hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>
    <hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>
    <hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>
    <hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>
    <hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>
    <hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>
    <hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>
    <a name="footer">
    Bottom of page
    
    </body>
    </html>
    When this page is loaded it moves to the location of the footer. Assuming this was the post page you could accept the name of the location as a post variable and then plug it in to the function so that when the page loads it goes to the spot you want. I only tested this in IE so it might need tweaking for other browsers.

    From the calling page you would need to pass the location that you want to move to in the target post page.

    I'm not certain you can move to a specific DIV position...I would have to research that.

    Hopefully this will get you going in the right direction.
    If I have been of help to you please consider making a
    donation for my time via PayPal here.
    Get a GREAT domain for under $20 each day via my
    STEAL of the DAY page.

  3. #3
    SitePoint Wizard WorldNews's Avatar
    Join Date
    Nov 2007
    Posts
    1,033
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    ThanX. This suggestion works fine.



    Quote Originally Posted by tacodomains View Post
    Look at this example:

    Code:
    <html>
    <script language="javascript">
    function MovePage()
    {
    	alert('moving page');
    	//location.replace=document.location.href+"#footer";
    	document.location.href=document.location.href+"#footer";
    }
    </script>
    <body onLoad="MovePage();">
    Top of page
    <hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>
    <hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>
    <hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>
    <hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>
    <hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>
    <hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>
    <hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>
    <hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>
    <hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>
    <hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>
    <hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>
    <hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>
    <hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>
    <a name="footer">
    Bottom of page
    
    </body>
    </html>
    When this page is loaded it moves to the location of the footer. Assuming this was the post page you could accept the name of the location as a post variable and then plug it in to the function so that when the page loads it goes to the spot you want. I only tested this in IE so it might need tweaking for other browsers.

    From the calling page you would need to pass the location that you want to move to in the target post page.

    I'm not certain you can move to a specific DIV position...I would have to research that.

    Hopefully this will get you going in the right direction.

    Anoox search engine volunteer

    www.anoox.com


Bookmarks

Posting Permissions

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