Hi there,
I am wondering how it would be possible to place a graphic on the browser which
sticks to the top, no matter how far you scroll down. I recently saw a banner
and do wonder how they did this.
Have a look http://www.spiegel.de
Is this a DHTML, Flash or JS thing? I was not able to find out.
Thank you for any hint.
Merlin 9 1481
Merlin wrote: I am wondering how it would be possible to place a graphic on the browser which sticks to the top, no matter how far you scroll down. I recently saw a banner and do wonder how they did this. Have a look http://www.spiegel.de Is this a DHTML, Flash or JS thing? I was not able to find out.
Browsers besides IE/Win can do that with CSS position: fixed e.g.
<style type="text/css">
#elementId {
position: fixed;
top: 0;
right: 0;
}
</style>
in the head of the document and then
<img id="elementId"
src="banner.gif"
alt="whatever">
--
Martin Honnen http://JavaScript.FAQTs.com/
And so with IE when the user moves down the page you have to
dynamically change it's location in regard to the top of the window.
Mike
code snippet:
if(document.compatMode != 'CSS1Compat')
{
document.body.scrollTop = '0px';
}
else
{
window.document.documentElement.scrollTop = '0px';
}
you just have to call that whenever the page is scrolled or use an
interval to call it every x microseconds.
have a look at http://dean.edwards.name/IE7/, his ie7 fixes any kind of
ie css problems in ie, but takes rather a lot of system ressources
(that's why i do not use it for just correcting one div).
good way there to implement patches for ie too: http://dean.edwards.name/IE7/usage/
micha
maybe not clear from my 1st post: this snippet is only needed for ie,
all other browser will work with position:fixed.
and i forgot one more thing:
if you use position:fixed you need to set position to absolute for ie
before trying to scroll.
this line should be 1st line in above snippet:
YOUR_ELEMENT.style.position = 'absolute';
micha
chotiwallah wrote: code snippet:
if(document.compatMode != 'CSS1Compat') { document.body.scrollTop = '0px'; } else { window.document.documentElement.scrollTop = '0px'; }
you just have to call that whenever the page is scrolled or use an interval to call it every x microseconds.
have a look at http://dean.edwards.name/IE7/, his ie7 fixes any kind of ie css problems in ie, but takes rather a lot of system ressources (that's why i do not use it for just correcting one div). good way there to implement patches for ie too: http://dean.edwards.name/IE7/usage/
micha
Hi Micha,
Martin and you are right, the code works excellent on all non IE browsers:
<style type="text/css">
#elementId {
position: fixed;
top: 0;
right: 0;
}
</style>
in the head of the document and then
<img id="elementId"
src="banner.gif"
alt="whatever">
The spiegel site seems to have done it just that way since in IE the site
clearly shows a movement of the graphic on scroll while it does not with firefox.
I must admit that I did not understand your code as I am a bit a newbie when it
comes to JS. Could you create an working example code for me? That would be great.
Thank you in advance,
Merlin
2 files (change path if they're not in the same dir on your site)
i leave out stuff not needed for functionality
page.htm
ie-fix.js
page.htm (relies on a bug, actually: only ie executes js in comments)
<html>
<head>
ALL meta tags
<!--[if lt IE 7]>
<script src="ie-fix.js" type="text/javascript">
</script>
<![endif]-->
</head>
<body>
<div style="position:fixed" id="FIXIT">some text</div>
... rest of document
ie-fix.js:
function fix()
{
//handle for the div
$fix = document.all.FIXIT;
//i don't remember why i put in this line
if(typeof($fix) == 'object')
{
//making position understandable for ie
$fix.style.position = 'absolute';
//finding out scroll position of document and putting div at
the top of the screen
if(document.compatMode != 'CSS1Compat')
{
$fix.style.top = document.body.scrollTop;
}
else
{
$fix.style.top = window.document.documentElement.scrollTop;
}
}
//setting an intervall to call fix() every 1000 microseconds
$int = window.setInterval("fix()", 1000);
that's it. hope it works, i didn't test. post if it's not ok, i'm
watching this topic
micha
Hi,
thank you for the example. It workes for IE if the tag is absolute:
<!--[if lt IE 7]>
<script src="/x_dev/scroll.js" type="text/javascript"></script>
<![endif]-->
<img style="position: absolute; top: 0; left: 774;" class="positon"
src="/g/p/tmp/test_right.gif">
but it should be fixed for other than IE.
Any idea on how to include an else into this if lt IE thing?
Thanx,
Merlin
chotiwallah wrote: 2 files (change path if they're not in the same dir on your site)
i leave out stuff not needed for functionality
page.htm ie-fix.js
page.htm (relies on a bug, actually: only ie executes js in comments)
<html> <head> ALL meta tags
<!--[if lt IE 7]> <script src="ie-fix.js" type="text/javascript"> </script> <![endif]-->
</head> <body> <div style="position:fixed" id="FIXIT">some text</div>
.. rest of document
ie-fix.js:
function fix() { //handle for the div $fix = document.all.FIXIT; //i don't remember why i put in this line if(typeof($fix) == 'object') { //making position understandable for ie $fix.style.position = 'absolute'; //finding out scroll position of document and putting div at the top of the screen if(document.compatMode != 'CSS1Compat') { $fix.style.top = document.body.scrollTop; } else { $fix.style.top = window.document.documentElement.scrollTop; } }
//setting an intervall to call fix() every 1000 microseconds $int = window.setInterval("fix()", 1000);
that's it. hope it works, i didn't test. post if it's not ok, i'm watching this topic
micha
For javasript,ecmascript, or jscript to detect IE,
use something like
var bIsIE = document.all
THAT is detection from script.
---------------
conditional comment methods in IE won't work with xml/xsl at this time.
e.g. web.xml !--> <!-- [ when Opera/Netscape/Forefox use css else xsl ]>
"Merlin" <ng*****@fastmail.fm> wrote in message
news:3j************@individual.net... Hi,
thank you for the example. It workes for IE if the tag is absolute: <!--[if lt IE 7]> <script src="/x_dev/scroll.js" type="text/javascript"></script> <![endif]--> <img style="position: absolute; top: 0; left: 774;" class="positon" src="/g/p/tmp/test_right.gif">
but it should be fixed for other than IE.
Any idea on how to include an else into this if lt IE thing?
Thanx,
Merlin
chotiwallah wrote: 2 files (change path if they're not in the same dir on your site)
i leave out stuff not needed for functionality
page.htm ie-fix.js
page.htm (relies on a bug, actually: only ie executes js in comments)
<html> <head> ALL meta tags
<!--[if lt IE 7]> <script src="ie-fix.js" type="text/javascript"> </script> <![endif]-->
</head> <body> <div style="position:fixed" id="FIXIT">some text</div>
.. rest of document
ie-fix.js:
function fix() { //handle for the div $fix = document.all.FIXIT; //i don't remember why i put in this line if(typeof($fix) == 'object') { //making position understandable for ie $fix.style.position = 'absolute'; //finding out scroll position of document and putting div at the top of the screen if(document.compatMode != 'CSS1Compat') { $fix.style.top = document.body.scrollTop; } else { $fix.style.top = window.document.documentElement.scrollTop; } }
//setting an intervall to call fix() every 1000 microseconds $int = window.setInterval("fix()", 1000);
that's it. hope it works, i didn't test. post if it's not ok, i'm watching this topic
micha
commercial wrote: For javasript,ecmascript, or jscript to detect IE,
use something like
var bIsIE = document.all
<snip>
In what sense does assigning a local variable a reference to an object
on IE, Opera, IceBrowsers, Safari, Konqueror, Omniweb, iCab, Netfront,
etc, and an Undefined value on Netscape, Mozilla, Firefox, Escape, etc,
represent using "javasript, ... to detect IE"?
"Merlin" <ng*****@fastmail.fm> wrote in message news:3j************@individual.net...
<snip>
Please do not top-post on comp.lang.javascript.
Richard. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Rothrock |
last post by:
I trying to build a navigation bar for my company's website.
We have different sections, Home, About, Product, etc.
I have made the graphics and the basic JS for the Rollovers.
To indicate...
|
by: hamil |
last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview
control, the PageSetup control, and the Print dialog control. The code
attached is a concatination of two examples taken out...
|
by: Uriah Piddle |
last post by:
Hi Gang,
I've given up looking and I am pretty sure it does not exist but I thought I
should do a post just in case I'm wrong: I am making an online forum in VS
2005 using the ASP GridView. I...
|
by: dac |
last post by:
I am quietly going insane on this project. I've never worked on a project like this one before. All my previous sticky forms were for data entry, not editing. I don't know how to display the form...
|
by: icepick72 |
last post by:
On an academic note, I want to copy a Graphic to an Image (Bitmap).
I have the Graphic object but not the origin image from which it
originates; this is because I'm overriding the PrintDocument...
|
by: Cruelemort |
last post by:
All,
I have a requirement to build a div in a page that contains a table of
plane details, and one of the columns (on the left - tail number)
needs to be sticky on the horizontal axis but not on...
|
by: student4lifer |
last post by:
Hello,
could someone show me how to make sticky form with dynamically
generated form element? for example, if one likes to make the
dynamically generated check box (and its name) 'sticky' that...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |