473,575 Members | 3,311 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 1692
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
12150
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
11171
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...
1
1592
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...
3
16524
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
3069
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
7284
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
7478
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...
6
6969
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
6466
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...
0
8115
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. ...
0
8278
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...
1
7865
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...
0
6514
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5660
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...
0
3776
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2283
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1378
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1103
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...

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.