473,837 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

safari compatibility, drosera useless

Tom
I have an oo-type javascript program running perfectly on IE 6.0+, FF
1.5+, and Opera 7+ on Windows 98+, Linux (RH 9, FC 6), and Mac OS X.
4. As usual, the Safari browser is not working correctly, and because
it lacks an internal debugger, I'm completely unable to see what the
problem is.

So I downloaded that "Drosera" debugging program, but I'm finding it
useless for the following reasons:

1) I cannot "Attach" it to Safari 2.0 directly -- it only allows me to
attach it to this WebKit program, which looks like a Safari clone of
some kind?
2) My program works perfectly in WebKit and produces no errors! I
need to see the errors in Safari 2.0, not this WebKit build, whatever
it is.

You can see the script here:
http://www.biegeldesigns.com/projects/preload.php

People keep telling me to keep an open mind about Macs and web
development, but situations like these are infuriating, waste time,
and make me even more attached to Linux or even Windows.

Any help would be appreciated!

Feb 20 '07 #1
7 2558
ASM
Tom a écrit :
I have an oo-type javascript program running perfectly on IE 6.0+, FF
1.5+, and Opera 7+ on Windows 98+, Linux (RH 9, FC 6), and Mac OS X.
4. As usual, the Safari browser is not working correctly, and because
it lacks an internal debugger, I'm completely unable to see what the
problem is.
Safari's console tells "undefined value" without other precision

Why do you use a so complicated code to do something quite simple ?

I'll pass on html with a table (that do not simplify JS actions)

<script type="text/javascript">
function init() {
I = document.images ;
A = [];
postload(0,I.le ngth);
}
function postload(k, max) {
if(k<max) {
A[k] = new Image();
A[k].onload = function() {
var o = I[k].parentNode.par entNode.parentN ode;
o = o.getElementsBy TagName('TD');
var m = o[1].getElementsByT agName('DIV')[0];
m.innerHTML = 'loaded';
m = o[0].getElementsByT agName('A')[0];
m.href = 'javascript:dis playImage(A['+k+'].src);';
k++;
postload(k, max);
}
A[k].src = I[k].src.replace(/.tmb/,'');
}
}
function displayImage(wh at) {
var I = document.getEle mentById('image _full');
I = I.getElementsBy TagName('TD')[0];
if(typeof(what) =='undefined' || !what ||
what.toString() .indexOf('http' )<0) {
I.innerHTML = 'Please wait complete loading !';
I.style.backgro und = '';
}
else {
I.innerHTML = '&nbsp;';
I.style.backgro und = 'url('+what+') no-repeat center center';
}
}
onload = init;
</script>

And it works fine with my Safari 1.3.2
as with my FF 2.0.1
or my Opera 9
and even with my IE 5.2 (Mac)

Without needing a list of big images,
using only urls of thumbnails.
(no need IDs of elements, except this of "viewer"
(that we haven't on your page ==head hack in JS to reach it)
Most of the JS up there is to try to find and organize where things are
in the table :-(
You can see the script here:
http://www.biegeldesigns.com/projects/preload.php
Any help would be appreciated!
Try to use cleverly CSS instead of tables.

The first one could be :

<div id="thumbnails" >
<dl>
<dt><a href="javascrip t:displayImage( )">
<img src="....tmb.jp g" alt="thumbnali" title="" />
<a>
<dd></dd>
<dl>
<dl>
<dt><a href="javascrip t:displayImage( )">
<img src="....tmb.jp g" alt="thumbnali" title="" />
<a>
<dd></dd>
<dl>
.... etc ...
</div>

And second one :

<div id="viewer">
I dare you to stop the preload sequence!
</div>
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Feb 20 '07 #2
Tom
Thank you for your detailed reply, but the object-oriented method is
much more portable and flexible, and doesn't rely on all the string
literals present in the example page. I also don't feel I should have
to "downgrade" the javascript because of a DOM hole in Safari.

I've found another programmer who has the exact same problem I do:

http://www.thescripts.com/forum/thread451890.html

The fact that it works in WebKit AND Konqueror, but not the current
Safari release leads me to believe this is a bug unique to Safari.

Can anyone else confirm that when you assign the onload event handler
to an Image object in Safari, that the event object defaults to the
Window object, not the Image object as expected?

e.g.:

function Preload {
var thisImage = new Image() ;
thisImage.onloa d = Preload.prototy pe.onload;
thisImage.src = "whatever" ;
}
Preload.prototy pe.onload = function() {
alert(this) ;
}

// Safari will alert "object Window";
// all other browsers alert "object Image", or whatever variant the
browser returns, e.g. [object Image], [object] Image, etc.

Thanks
On Feb 20, 11:24 am, ASM <stephanemoriau x.NoAd...@wanad oo.fr.invalid>
wrote:
Tom a écrit :
I have an oo-type javascript program running perfectly on IE 6.0+, FF
1.5+, and Opera 7+ on Windows 98+, Linux (RH 9, FC 6), and Mac OS X.
4. As usual, the Safari browser is not working correctly, and because
it lacks an internal debugger, I'm completely unable to see what the
problem is.

Safari's console tells "undefined value" without other precision

Why do you use a so complicated code to do something quite simple ?

I'll pass on html with a table (that do not simplify JS actions)

<script type="text/javascript">
function init() {
I = document.images ;
A = [];
postload(0,I.le ngth);}

function postload(k, max) {
if(k<max) {
A[k] = new Image();
A[k].onload = function() {
var o = I[k].parentNode.par entNode.parentN ode;
o = o.getElementsBy TagName('TD');
var m = o[1].getElementsByT agName('DIV')[0];
m.innerHTML = 'loaded';
m = o[0].getElementsByT agName('A')[0];
m.href = 'javascript:dis playImage(A['+k+'].src);';
k++;
postload(k, max);
}
A[k].src = I[k].src.replace(/.tmb/,'');
}}

function displayImage(wh at) {
var I = document.getEle mentById('image _full');
I = I.getElementsBy TagName('TD')[0];
if(typeof(what) =='undefined' || !what ||
what.toString() .indexOf('http' )<0) {
I.innerHTML = 'Please wait complete loading !';
I.style.backgro und = '';
}
else {
I.innerHTML = '&nbsp;';
I.style.backgro und = 'url('+what+') no-repeat center center';
}}

onload = init;
</script>

And it works fine with my Safari 1.3.2
as with my FF 2.0.1
or my Opera 9
and even with my IE 5.2 (Mac)

Without needing a list of big images,
using only urls of thumbnails.
(no need IDs of elements, except this of "viewer"
(that we haven't on your page ==head hack in JS to reach it)
Most of the JS up there is to try to find and organize where things are
in the table :-(
You can see the script here:
http://www.biegeldesigns.com/projects/preload.php
Any help would be appreciated!

Try to use cleverly CSS instead of tables.

The first one could be :

<div id="thumbnails" >
<dl>
<dt><a href="javascrip t:displayImage( )">
<img src="....tmb.jp g" alt="thumbnali" title="" />
<a>
<dd></dd>
<dl>
<dl>
<dt><a href="javascrip t:displayImage( )">
<img src="....tmb.jp g" alt="thumbnali" title="" />
<a>
<dd></dd>
<dl>
... etc ...
</div>

And second one :

<div id="viewer">
I dare you to stop the preload sequence!
</div>

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date

Feb 22 '07 #3
VK
On Feb 22, 11:40 pm, "Tom" <bie...@gmail.c omwrote:
// Safari will alert "object Window";
// all other browsers alert "object Image", or whatever variant the
browser returns, e.g. [object Image], [object] Image, etc.
Check maybe they didn't screw up on W3C model:

function imageLoadListen er(e) {
window.alert(e. target);
window.alert(e. relatedTarget);
}

var img = new Image;
img.onload = imageLoadListen er;
document.body.a ppendChild(img) .src = 'some/URL';
btw I did not see you adding new images into document - though I may
missed it. You don't suppose to receive onload notifications right
from the browser cache, for "purely virtual" images. Neither browser
supposes to download and cache an image just because you created Image
object and set .src attribute for it. Some browsers do provide this
convenience out of their good heard but don't make any strong
assumptions in this regard.

Feb 22 '07 #4
On Feb 23, 6:40 am, "Tom" <bie...@gmail.c omwrote:
Thank you for your detailed reply, but the object-oriented method is
Please don't top-post here. Reply below trimmed quotes.

much more portable and flexible, and doesn't rely on all the string
literals present in the example page. I also don't feel I should have
to "downgrade" the javascript because of a DOM hole in Safari.
Your example is not particularly "object oriented". The Preload
function makes a pretence at being a constructor, but it is used like
a plain function. Its prototype is used essentially as a namespace,
it isn't used for inheritance. You could achieve exactly the same
result with:

<script type="text/javascript">

var preload = (function(){
return {
img: function(src){
var img = new Image();
img.onload = this.onload;
img.src = src;
},
onload: function(){
alert('Dynamic: ' + this);
}
}
})();

preload.img('ne ws.jpg');
</script>

<div id="xx">
<img src="news.jpg" onload="alert(' Inline: ' + this);">
</div>

[...]
Can anyone else confirm that when you assign the onload event handler
to an Image object in Safari, that the event object defaults to the
Window object, not the Image object as expected?
The issue isn't the event object, it's that if you dynamically assign
an event handler to the object returned by new Image, it's this
keyword is set to the window object, not the image object.

It is rectified by creating an img element rather than an Image
object. In the above code, replace:

var img = new Image();

with

var img = document.create Element('img');

and all is well.
--
Rob

Feb 23 '07 #5
On Feb 20, 11:17 pm, "Tom" <bie...@gmail.c omwrote:
[...]
You can see the script here:http://www.biegeldesigns.com/projects/preload..php
Image preloading is passé, I think it indicates poor design. Consider
loading the images in-line using normal HTML, then hide and show them
by tinkering with their CSS - visibility, display, z-index, whatever.

That should require less code and be easier to make cross-browser.

--
Rob

Feb 23 '07 #6
Tom
On Feb 23, 9:33 am, "RobG" <r...@iinet.net .auwrote:
On Feb 20, 11:17 pm, "Tom" <bie...@gmail.c omwrote:
[...]
You can see the script here:http://www.biegeldesigns.com/projects/preload.php

Image preloading is passé, I think it indicates poor design. Consider
loading the images in-line using normal HTML, then hide and show them
by tinkering with their CSS - visibility, display, z-index, whatever.

That should require less code and be easier to make cross-browser.

--
Rob
VK: To be honest, I had not even thought about browsers not loading
the image when given the src property -- I've tested this with
browsers that take up something like 99%+ of the usage shared,
according to W3Schools. Could you provide a name/version of a browser
that DOESN'T load the image when given a src attr?

RobG: I realize it's not an intended use of oo-javascript, but this
lib needs to be portable, and I want to avoid any chance of a third-
party developer accidentally redeclaring a function. Your example
solves the problem, but still does not explain why Safari acts in this
manner. It seems to me that in any oo-programming language, if you
create a new instance of a class (in this case, `Image`), and the
instance's `this` reference returns a DIFFERENT class name (in this
case, `Window`), there's no other explanation other than a bug. How
can one possibly justify returning a different class with the `this`
keyword? The fact that the more recent versions of WebKit act in line
with the other major browsers further leads me to believe that this is
just another Safari javascript problem.

I do agree with image preloading being out-of-date though. This is
for a freelance job though, so the client is the boss :-)

Thank you again --

Feb 25 '07 #7
On Feb 25, 12:22 pm, "Tom" <bie...@gmail.c omwrote:
[...]
RobG: I realize it's not an intended use of oo-javascript, but this
lib needs to be portable, and I want to avoid any chance of a third-
party developer accidentally redeclaring a function. Your example
solves the problem, but still does not explain why Safari acts in this
manner. It seems to me that in any oo-programming language, if you
create a new instance of a class (in this case, `Image`), and the
instance's `this` reference returns a DIFFERENT class name (in this
case, `Window`), there's no other explanation other than a bug.
I think you are straying from the issue here. Javascript doesn't have
classes, it isn't a classic OO language - the closest thing it has to
classes are objects created by constructors. The this keyword of
constructed objects has nothing to do with their constructor, in fact
it is extremely unlikely that it will ever refer to the constructor.

The issue here is that when you assign a function reference to an
Image object's onload property, you expect the Image object to be
referenced by the function's this keyword when the load event occurs
and calls the function. Problem is, you don't know how the event
calls the function. It's just a convention, and is a bug in Safari in
so much as it doesn't follow that convention.

It may have been a better idea if functions called by event handlers
had their this keyword set to the event object.

How
can one possibly justify returning a different class with the `this`
keyword?
The ECMAScript specification is clear on how a function's this word is
set, and it has nothing at all to do with an object's "class".

The fact that the more recent versions of WebKit act in line
with the other major browsers further leads me to believe that this is
just another Safari javascript problem.
Great! I wasn't defending Safari's non-conformance, only the notion
that it was somehow contrary to a language or DOM specification.
--
Rob

Feb 25 '07 #8

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

Similar topics

1
1933
by: liberty | last post by:
Hi, I have looked everywhere to try and solve my problem-- looked at W3C DOM Compatibility charts, read articles, tried debuggers, and still my script is not working. The problem I have is this. I am working on a script that dynamically generates maps with research sites that show up when selected from a pulldown list. The sites show up in every browser except for Safari, and I can't figure out why. I have made a simple function that...
2
1987
by: jdlwright | last post by:
Hi, I have a big script that doesn't work in Safari 1.3, but does work in FF, and IE. I've given up going to my local Uni. to use their Macs (they've prevented the Debug menu from appearing after running that widely known hack), and so I want to buy my first Mac to do this properly. Being a PC person I am generally ignorant of Mac OS issues;
2
2515
by: drew197 | last post by:
I am a newbie. This is someone else's code which I have to modify to work in Mozilla and Safari. The changes I made so far have allowed it to work in Mozilla but not Safari. It seems to be getting hung up on the first line of code. I put an alert after that line and I never saw it in Safari but I did see it in Mozilla. Any Thoughts? Thanks, Andrew Here's the code:
2
2120
by: Simon Wigzell | last post by:
I use onkeypress() within text fields in my forms to chcek certain characters e.g. allow numbers for a phone number or credit card field. The code looks at the key pressed and if it is not numberic it posts an alert and returns false. On everything I have looked at except safari on the mac, returning false to onkeypress() is enough that the newly typed character will not appear in the text field. On mac safari it does. Is there no way to...
34
3888
by: Simon Wigzell | last post by:
document...focus() will scroll the form to move the specified text field into view on everything I have tried it with except Safari on the MAC. The form doesn't move. Any work around? Thanks.
3
5417
by: Jeff Paffett | last post by:
I'm trying to use the onPaste event in a text input, which according to Apple is supported. However, I get no response in Safari. Firefox works fine.
5
4026
by: Peter Michaux | last post by:
Hi, I just did a bunch of testing and was surprised with the results. If anyone doesn't know this stuff here is what I found about event.clientX. The event.clientX property in Safari is in page coordinates. In IE, Opera, Firefox event.clientX it is in window coordinates. This means a lot when trying to determine event location in page
3
1943
by: dd | last post by:
I have a page that works just fine on all OS'es/Browsers except Safari. When I close the page I get a world leak triggered by the JavaScript Interpreter. I know most people don't have the "always check for world leaks" on, so it's not like it's going to happen for Joe user, but I've got some code that Safari's JS interpreter isn't happy with and I want to track it down. Just like I do with anything that appears in the Firefox console,...
0
9843
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
9682
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
10875
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...
1
10623
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
10272
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
7806
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
7001
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
5669
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
4474
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.