Results 1 to 3 of 3

Thread: How to set focus on iframe when menu link is clicked

  1. #1
    Join Date
    Mar 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Exclamation How to set focus on iframe when menu link is clicked

    Hey guys could anyone please tell me how to set focus on iframe or bottom of the page when any link is clicked from menu, it's really very urgent guys...

    Thanks in advance
    Shashaank Sharma

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,000
    Thanks
    44
    Thanked 3,198 Times in 3,160 Posts
    Blog Entries
    12

    Default

    There are a number of ways. It would depend on the page and the menu. I would try:

    1. getting a reference to the iframe as an element and firing its focus() function.

      Or:

    2. setting a hash that references a named anchor at the bottom of the page.

      Or:

    3. scrolling the window by a large amount.


    In the first scenario you can get a reference to the iframe if it has an id as:

    Code:
    document.getElementById('frame_id').focus();
    where frame_id is the id attribute of the iframe. Or if it has a name:

    Code:
    document.getElementsByName('frame_name')[0].focus();
    where frame_name is the name attribute of the iframe.


    In the second scenario, put a named anchor at the bottom of the page:

    HTML Code:
    <a name="bottom"></a>
    Then use this code to to seek the page to it:

    Code:
    window.location.hash = '#bottom';

    In the third scenario, just do:

    Code:
    window.scrollBy(0, 100000);

    If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    sha10oct (04-04-2012)

  4. #3
    Join Date
    Mar 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Smile

    @ jscheuer1 : Thanks a lot buddy, u solved my problem...

    "Dhanyawad"

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
  •