Body onload and document.location

nifa -  
 nifa -
Bonjour,

I have a PHP site.

I use <body onload="document.location.href='#top_image'"> so that certain pages are displayed directly at my anchor point. The problem is that the page opens at the "standard" location before scrolling to my anchor, which creates a kind of jump on the page, visually unpleasant. This only happens when the page is loaded for the first time. Then, if you navigate within the site and return to the page, it positions itself immediately at the anchor point without any visual jump. (same with window.location)

How can I avoid this "jump" when opening the page?

Thank you for your help.
Configuration: Windows Vista Internet Explorer 7.0 / FireFox 3.0.12

1 answer

Luan1604 Posted messages 141 Status Member 4
 
Everything depends on the PC, everything depends on the browser, in short, everything depends on everything...

On the first visit to a site, the rest of the elements of the page have to be loaded, then it's in the cache. Whatever you do, there will always be a flicker.

However, try a
<?php
header('Location: page.php#anchor');
?>

at the TOP of the pages. Before the doctype, in short, before EVERYTHING. It should go faster than JavaScript but I doubt it will completely eliminate the "flicker".

Luan.
--
1... 2... 3...
0
nifa
 
Thank you for the response. It doesn't work.

I have this at the beginning of my photo gallery page:

<?php if (!defined('WEBPATH')) die(); $themeResult = getTheme($zenCSS, $themeColor, 'light'); $firstPageImages = normalizeColumns('2', '6');?>

I tried putting the header in front of everything and just after, as well as between die(); and $themeResult,
but the page doesn't display at all. I also tried with a timeout, but there is no display either.
0