473,385 Members | 1,402 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

offsetTop and global variable in Safari 3

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 2082
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
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>...
2
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....
9
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...
4
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
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...
9
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
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 &...
1
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...
112
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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 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.