Welcome to WebmasterWorld Guest from 54.158.36.59

Forum Moderators: open

Message Too Old, No Replies

Change page focus

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

WebmasterWorld Senior Member 10+ Year Member



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?
7:42 pm on Apr 10, 2006 (gmt 0)

10+ Year Member



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

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

WebmasterWorld Senior Member 10+ Year Member



Awesome!
9:20 pm on Apr 15, 2006 (gmt 0)

5+ Year Member



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

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

WebmasterWorld Senior Member 10+ Year Member



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

gph

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

10+ Year Member



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

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

or

window.onload=myFunction;

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

WebmasterWorld Senior Member 10+ Year Member



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

Featured Threads

Hot Threads This Week

Hot Threads This Month