473,657 Members | 2,555 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can setting scroll top in IE trigger a redirect in Netscape?

I thought I was fighting a PHP problem, so I asked about this on a PHP
list, but they felt it was a Javascript problem, so I'm reposting a
bit of the debate here. Could this Javascript, below, possibly trigger
a redirect in Netscape, and send the browser to a file called "0".
Cause what is happening is on load, in Netscape, the page redirects to
something like:

http://www.myDomain.com/0


--- In ph******@yahoog roups.com, Bob Sawyer <bobsawyerdotco m@y...>
wrote
I don't think it's anything in the PHP - I think it's
your javascrpt, particularly this function:

------------------
function scrolltop() {
location = document.body.s crollTop;
if (location == 0) location =
document.docume ntElement.scrol lTop;
if (location == 0) location = window.pageYOff set;
document.getEle mentById('scrol lmenu').style.p ixelTop
= location;
gTimer1 = window.setTimeo ut('scrolltop() ',1000);
}
------------------

I'm terrible with javascrpt but I think that's where
your "0" is coming from...


Interesting thought. But I don't set the location to 0, I only test to
see if the scroll top is at 0 pixels. And I'm pretty sure I had this
function working in Netscape. And at no point do I reference the href.
So it's unlikely. But it is worth looking at. I'll repost all this to
a Javascript list.
Jul 23 '05 #1
2 1694
lawrence wrote:
I thought I was fighting a PHP problem, so I asked about this on a PHP
list, but they felt it was a Javascript problem, so I'm reposting a
bit of the debate here. Could this Javascript, below, possibly trigger
a redirect in Netscape, and send the browser to a file called "0".
Cause what is happening is on load, in Netscape, the page redirects to
something like:

http://www.myDomain.com/0


--- In ph******@yahoog roups.com, Bob Sawyer <bobsawyerdotco m@y...>
wrote
I don't think it's anything in the PHP - I think it's
your javascrpt, particularly this function:

------------------
function scrolltop() {
location = document.body.s crollTop;
if (location == 0) location =
document.docu mentElement.scr ollTop;
if (location == 0) location = window.pageYOff set;
document.getEle mentById('scrol lmenu').style.p ixelTop
= location;
gTimer1 = window.setTimeo ut('scrolltop() ',1000);
}
------------------

I'm terrible with javascrpt but I think that's where
your "0" is coming from...

Interesting thought. But I don't set the location to 0, I only test to
see if the scroll top is at 0 pixels. And I'm pretty sure I had this
function working in Netscape. And at no point do I reference the href.


location and location.href are normally the same thing, in the way that
you are referencing them. location is a bad variable name. Try changing
it to thisLocation (anything but location) and see what happens with it.
So it's unlikely. But it is worth looking at. I'll repost all this to
a Javascript list.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/
Jul 23 '05 #2
DU
lawrence wrote:
I thought I was fighting a PHP problem, so I asked about this on a PHP
list, but they felt it was a Javascript problem, so I'm reposting a
bit of the debate here.
Thanks for clarifying this.

Could this Javascript, below, possibly trigger a redirect in Netscape, and send the browser to a file called "0".
Cause what is happening is on load, in Netscape, the page redirects to
something like:

http://www.myDomain.com/0


--- In ph******@yahoog roups.com, Bob Sawyer <bobsawyerdotco m@y...>
wrote
I don't think it's anything in the PHP - I think it's
your javascrpt, particularly this function:

------------------
function scrolltop() {
location = document.body.s crollTop;

document.body.s crollTop is a number (typeof "number"), like 34, 843 or
3.14159
location (and location.href) on the other hand is a window property
storing an uri value like http://www.yahoo.com or
ftp://www.downloadDomain.com/
Normally, a good browser/javascript console would (should?) have
reported a type mismatch somehow. I think the scrollTop value is
converted into a string.

Addendum:
Here, you definitively have a problem. Either you're declaring and
defining a global variable to store that scrollTop value or you're
assigning the location property of the window object. Either way, you
really should not use the "location" identifier like you do in your
chunck of code.

if (location == 0) location =
document.docu mentElement.scr ollTop;
if (location == 0) location = window.pageYOff set;
You seem to be wanting to execute the same instruction for browsers
implementing different DHTML object model. At least, you should have
coded a branch code
(with an if(){instructio n[s];} else structure)
depending on the support for a particular object property.
document.getEle mentById('scrol lmenu').style.p ixelTop
= location;
I can assure you that Netscape 7.x and Mozilla-based browsers do not
support pixelTop.
gTimer1 = window.setTimeo ut('scrolltop() ',1000);
If your user does not scroll the window nor the document view at all,
say for 200 seconds, then this scrollTop() function will be executed
anyway and 200 times. For sure, you have to assume that most of the
time, your users will be reading your document and won't be scrolling
the document.
Here, I point out an abuse/poor usage of user's system resource.
Remember that some people have modest system resources (cpu, RAM, modem
speed, ISP bandwidth). The ideal would be to reposition that scrollmenu
of yours when *and only when* a scroll event on the window is fired.
}
------------------

I'm terrible with javascrpt but I think that's where
your "0" is coming from...

Interesting thought. But I don't set the location to 0, I only test to
see if the scroll top is at 0 pixels. And I'm pretty sure I had this
function working in Netscape. And at no point do I reference the href.
So it's unlikely. But it is worth looking at. I'll repost all this to
a Javascript list.

First of all, when you post, you should not assume that your solution is
correct. You should rather first of all describe, explain what you want
to achieve, and this, preferably along with a provided url where readers
of your post can see what you have done so far, can check the http
headers if needed, can verify markup validation of your document.
Here, I assume you want that scrollmenu of yours to remain fixed in the
browser viewport, at the top of the viewport. If so, then, say, in your

CSS stylesheet:
#idMenuFixedInV iewport {width: 250px; position: absolute; top: 100px;
left: 150px; border: 2px solid green; background-color: white;}
body>div#idMenu FixedInViewport {position: fixed;}

and in your HTML code:
<div id="idMenuFixed InViewport">(.. .)</div>

would do the trick for browsers supporting position: fixed;. You would
then need a javascript function for MSIE 5+: I did it with 10 lines of code.

Second, when you code, best is to avoid duplicating the name of
variables with keyword attributes, methods, functions. This for many
reasons: code readability, code reviewing by others, and, very
important, scope of variables not interacting/conflicting with keyword
attributes/methods/functions.
Here, location as a global variable and scrollTop as a function name are
bad names. In some cases, browsers can confuse the scope of function
name with a property or method of the window object: I know a precise
case of such.

Third, one way to reduce conflicts, memory load, memory management on
the user's side is to scope variables and references wisely: a local
variable is used differently from a global variable. Whenever possible,
reduce the number of global variables to a minimum.

The following file has been tested, is valid, should meet your webpage
requirements and is working on Opera 7.51, Mozilla 1.7 RC2, K-meleon
0.8.2, MSIE 6 SP1a, NS 7.1 (and it should work in a large number of
browsers):

http://www10.brinkster.com/doctorunc...tionFixed.html

DU
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
12156
by: lukeo | last post by:
I'm shelling out to an .asp (or htm) page from an application. I want to show this in a window without the address bar, etc... Is there a way I can redirect this page using javascript to a page where I can set the window height, statusbar=no, etc? Thanks, -Luke
1
11177
by: relaxedrob | last post by:
Howdy All! I am really stuck with this one - I want to completely create a table within JavaScript and insert it into the document, with onMouseOut and onMouseOver handlers in the table rows. Below is a sample of the code I have created. It all works in Netscape 7.1, but in IE 6 it shows the table but the handlers do not run. I can prove the handlers are even there (see the commented out alert command in the code) so why aren't they...
1
1594
by: Kjell Breimo | last post by:
Hi, I have made a selectbox (<Select....><option...>...) with size=1(It has to be size=1). It contains about 40 elements. It is placed on the top of my webpage abd I would like to see as many elements as possible when it is opened. As default there is only 12 elements that shows and then I have to scroll down to the other 28 elements. Is there a way to set the selectbox to show more than 12 elements when its opened?
3
16526
by: David Rwj Cherry CS2000 | last post by:
is there any way to disable or lock vertical scroll bars on a browser window? im a newbie and i just don't want them to appear on my screen. sometimes they appear on IE but not on mozilla. any ideas would be most appreciated.
2
3071
by: Elisa | last post by:
I have two images, each with defined CSS hover states. I would like a mouseover on one image to trigger the hover state of the other image. Is this possible using javascript? If so, how? Any help would be appreciated. Thanks, CJ
1
7287
by: Rob Webster | last post by:
Hi, is there a way using JavaScript to tell a textarea to scroll to the end of it's contents? I'm implementing something that looks like messenger using web forms, after each post the chat area gets updated but I have to manually scroll it down to the end. Rob
1
7484
by: alvinpoon | last post by:
Hello, I have a problem setting the scrollbar position of a div region on a webpage which is posted at http://www.geocities.com/virtuosity999/Logon.htm If the page is loaded with Netscape, the vertical scrollbar on the left side will be moved down a little bit but if the page is loaded with Internet explorer, the scrollbar remains at the top of the scroll area.
6
6974
by: Peter Krikelis | last post by:
Hi All, I am having a problem setting up input mode for serial communications. (Sorry about the long code post). The following code is what I use to set up my comm port.
1
6476
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting" setting to be "E_ALL", notices are still not getting reported. The perms on my file are 664, with owner root and group root. The php.ini file is located at /usr/local/lib/php/php.ini. Any ideas why the setting does not seem to be having an effect? ...
0
8403
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8316
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8833
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8737
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8509
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8610
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6174
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5636
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
1730
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.