Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Always On Top Button

Status
Not open for further replies.

WebNickson

Programmer
Dec 8, 2003
46
0
0
SG
Hi,

Can someone teach me how to do a "Always On Top Button"
using the simplest code possible? I only need it to work in IE.

Thx in advance.

rgds,
Nickson
 

<input type=&quot;button&quot; value=&quot;Always On Top&quot;>


but if what you really want to know is &quot;How do I make the browser window 'Always on top'?&quot;

You can't from a browser. It's a OS function call. (Well maybe via the WSH it could be done).

you can bring a window to the front with this
<SCRIPT TYPE=&quot;text/javascript&quot;>
<!--
window.focus();
//-->
</SCRIPT>



Chris.

Indifference will be the downfall of mankind, but who cares?
 

lol... that was funny on the <input type=&quot;button&quot; value=&quot;Always On Top&quot;>. You brighten my day with this joke since I hitting with lots of scripting problem today!

Anyway, what I wanted is a button that is always at a fix location(lower right corner) in the browser. The button remains at that position even though you scroll down.

Also, if I am not mistaken, it is possible to have a window always appearing on top.


rgds,
Nickson
 
You would have to use DHTML effects to keep the button following the scroll otherwise absolute positioning with CSS would work.

maybe try the javascript forum for some ideas.

Among my script snippets I have some code for this. I'll look it out later in the day. (heading out into the real world)




Chris.

Indifference will be the downfall of mankind, but who cares?
 
<body onscroll=&quot;update()&quot;>
<script>
var constantX=20;
var constantY=document.body.clientHeight-50;

document.write('<input type=&quot;button&quot; id=&quot;myButton&quot; style=&quot;position:absolute;top:'+constantY+';left:'+constantX+'&quot;

value=&quot;See me?&quot; onclick=&quot;alert(\'Yay! You can still see me\')&quot;>');

var m = document.getElementById('myButton');

for (var c=0;c!=200;c++) document.write('<br>'); // just white space



function update(){


m.style.left=document.body.scrollLeft+constantX;
m.style.top=document.body.scrollTop+constantY;

} // end update

</script>




</body>

----------
I'm willing to trade custom scripts for... [see profile]
 
P.S. There shouldn't be any line breaks in the long document.write() - that may need fixing if you copy & paste the code :)

----------
I'm willing to trade custom scripts for... [see profile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top