473,977 Members | 2,054 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

offsetTop and global variable in Safari 3

8 New Member
Hello all,

I have a problem with a scrript in safari 3. in mozilla/firefox and opera the problem does not exist.

what i try to do: I have a div element with overflow:auto. in the element i have several anchors, wich i can scroll to with several anchor links. this works quite nicely.
the div content can be scrolled by a JS-scrolling script. when i click on a anchor link the scrolling script loses its position, so the next time i will scroll, it will scroll from where i was before i was clicking the anchor link. to prevent this ive set a global variable, that saves the actual position of the scrolled text. the crolling script is then using this variable to scroll from the actual position.
this is all working fine except in safari 3 (mac).

the problem seems to be that safari somehow does not like to handel the gloabl variable or the offsetTop values.

to demonstrate what i mean ill post an example here:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.         var scrollCursorGlobal = 1;
  3. </script>
  4. <a href="test.php#3" onclick="scrollCursorGlobal=(document.getElementById('3').offsetTop-8);alert((document.getElementById('3').offsetTop-8));">test</a>
  5. <div id="testdiv" style="height:100px; float:left; overflow: auto; width:140;">
  6.     <br>
  7.     test1
  8.     <br>
  9.     text text text text text text text text text text text text text text text text 
  10.     text text text text text text text text text text text text text text text text 
  11.     text text text text text text text text text text text text text text text text 
  12.  
  13.     <a name="2" id="2"></a>
  14.     <br>
  15.     test2
  16.     <br>
  17.     text text text text text text text text text text text text text text text text 
  18.     text text text text text text text text text text text text text text text text 
  19.     text text text text text text text text text text text text text text text text 
  20.  
  21.     <a name="3" id="3"></a>
  22.     <br>
  23.     test3
  24.     <br>
  25.     text text text text text text text text text text text text text text text text 
  26.     text text text text text text text text text text text text text text text text 
  27.     text text text text text text text text text text text text text text text text 
  28. </div>
  29.  
has anybody a idea how to do this in safari? iam kind of stuck. offsetTop is available for safari and global JS variables uasually also. so i dont see the problem.

would appreciate a hint in the right direction :-)

if something is not clear, please let me know.

thanks

tobias
Dec 16 '07 #1
1 2113
tromton
8 New Member
ok, I solved the problem diffrently. ive dit some changes to the scrolling script. i wasssent aware that i actually can get the actual scrolling position of the div by asking scrollTop. this way i dont have to track changes to the scrolling position, but can simply jaust scroll from the actual scrolling position by asking scrollTop.

best
Dec 16 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
102771
by: David Hitillambeau | last post by:
Hi guys, As I am new to Python, i was wondering how to declare and use global variables. Suppose i have the following structure in the same module (same file): def foo: <instructions> <instructions> def bar: <instructions>
2
4313
by: Gernot Frisch | last post by:
Hi, when I have this code in my script: pos_y = document.getElementById('holdmenu').offsetTop; The menu get's positioned at the very top of the site - really annoying. On FireFox it works good. If I put this script part at the very end of the body, it works, too. Can you help me what's wrong here?
9
2259
by: lkrubner | last post by:
I've got a function, you can see it below, that is being called onmouseup in the textarea on my main form. The idea is to find a selection if possible and store that text in a global variable. I can't get this to work in any browser on a Mac, though it works alright on a PC. What am I missing?
4
5563
by: Pf | last post by:
A piece of html code: <table> <tr> <td> <input type="text" name="myInput" onclick="myFunction(this)"> <td> </tr> </table>
6
7753
by: Francisco | last post by:
Hi all, I have a div (divI) inner another div (divM), when i request the offsetTop of divI (inner) it returns me the top of divI in divM and not the top of divI in the document? Have anyway to get this information? Gratefull Francisco
9
3056
by: Ed Jensen | last post by:
I'm having a vexing problem with global variables in Python. Please consider the following Python code: #! /usr/bin/env python def tiny(): bar = for tmp in foo: bar.append(tmp) foo = bar
1
5053
by: Tarik Monem | last post by:
OK, you guys have helped me when I couldn't help myself, well I could but I couldn't if you know what I mean. So, here's another that I'm having issues with for just Safari -- tested in Firefox & Opera & IE (mac -- yeah -- I still test IE5 on mac -- things are not perfectly aligned but the functionality works) -- why wouldn't it work in Safari (beta 3) Basically the function below is called when a onclick is clicked -- Now, it moves the...
1
29445
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have called it polluting the global namespace. This article explores what happens when the global namespace becomes polluted and how to avoid this condition. The opinions expressed in this article are those of the author alone although many have...
112
5615
by: istillshine | last post by:
When I control if I print messages, I usually use a global variable "int silent". When I set "-silent" flag in my command line parameters, I set silent = 1 in my main.c. I have many functions that may print some messages. foo(...) { if (!silent)
0
10356
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
11823
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
11409
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
11578
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
10913
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...
0
10085
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7608
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();...
0
6418
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
5158
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

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.