View Full Version : How to set focus on iframe when menu link is clicked
sha10oct
03-31-2012, 10:59 AM
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
jscheuer1
03-31-2012, 04:25 PM
There are a number of ways. It would depend on the page and the menu. I would try:
getting a reference to the iframe as an element and firing its focus() function.
Or:
setting a hash that references a named anchor at the bottom of the page.
Or:
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:
document.getElementById('frame_id').focus();
where frame_id is the id attribute of the iframe. Or if it has a name:
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:
<a name="bottom"></a>
Then use this code to to seek the page to it:
window.location.hash = '#bottom';
In the third scenario, just do:
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.
sha10oct
04-04-2012, 09:35 AM
@ jscheuer1 : Thanks a lot buddy, u solved my problem...
"Dhanyawad"
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.