homepage Welcome to WebmasterWorld Guest from 54.211.47.170
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Change page focus
ahmedtheking




msg:1473544
 2:03 pm on Apr 10, 2006 (gmt 0)

Just a quickie, is it possible to write some javascript (in a simple <script> ... </script>) that changes the browser's focus to a certain id?

 

ChadSEO




msg:1473545
 7:42 pm on Apr 10, 2006 (gmt 0)

ahmedtheking,

Yes, you can do something like this:

<script>
document.getElementById('someID').focus();
</script>

Usually you want to do it in the body tag in the onLoad event, ala:

<body onload="document.getElementById('someID').focus();">

Chad

ahmedtheking




msg:1473546
 7:23 am on Apr 11, 2006 (gmt 0)

Awesome!

randompunter




msg:1473547
 9:20 pm on Apr 15, 2006 (gmt 0)

hi, if you open a popup through a link can you set the focus to the link rather than have the browser jump to the top of the page this happens with

<a href="" onclick="openpop(features)"></a>
or"#"
Cheers

ahmedtheking




msg:1473548
 11:44 am on Apr 16, 2006 (gmt 0)

Yeah, I know that much, just wanted to know how to make it automatic without having to add to the <body> tag.

gph




msg:1473549
 2:42 pm on Apr 16, 2006 (gmt 0)

just wanted to know how to make it automatic without having to add to the <body> tag.

window.onload=function(){
...
}

or

window.onload=myFunction;

ahmedtheking




msg:1473550
 8:19 pm on Apr 16, 2006 (gmt 0)

Ok, i'll try all these methods out, thank you!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved