View Full Version : Safari headaches :(
Hi all
I have recently taken up a large DOM scripting project, and I'm almost done , but I ran into a problem when trying to dynamically add a dblclick event to a node.
It works flawlessly in IE6, FF, Opera, and NN8
but nothing doing in Safari( :mad: Why is it Always Safari!). I enabled the hidden debug menu for Safari, and yet I don't get any error messages in the javascript console either
heres the function I use to add the event
(I modified some code I found on quirksmode so it would take some arguments)
function addEvent(obj,evt,func,args){
f_ref = (args)?function(event){ func(event,args);}:function(event){ func(event);};
if(obj.addEventListener){
evt=evt.toLowerCase();
if(evt.indexOf("on") == 0)evt=evt.substring(2,evt.length);
obj.addEventListener(evt, f_ref,false);
}else if(obj.attachEvent){
return obj.attachEvent(evt,f_ref);
}else{
alert('addEvent: \n No Way!\n'+ arguments.caller +'\n'+ evt);
return false;
}
}
anyone else run into this, or can point me in the right direction?
Thanks
jscheuer1
06-16-2006, 10:47 PM
The problem may lie in Safari's way of handling the double click. Have you checked the event compatibility tables at Quirksmode to see if Safari supports a javascript dblclick? Even if it does, perhaps it gets confused between what is a double and what is a single click. Attaching to both events on the same element can often cause problems in any browser. Always best to keep these things as simple as possible. If this project is in any way related to some 'content protection' scheme, best to forget the whole thing as, your content is protected by copyright. Any other form of protection only creates problems for honest people. Folks bent on taking content from a site can find a way no matter what you do.
yea, I've plugged through the Quirksmode archives, and drudged through the w3schools documentation, .....and utilized half my bookshelf on safari online....
and this is what I've found:
1. Safari support the dblclick event (used their test page to verify it on the 5 Macs @werk)
2. Not a content scheme.. I add the events to trigger a function that toggles the contents of a table cell back and forth from editable(select, text, checkbox) to a regular text filled cell.
3. no click event is established, only dblclick (aside from the select box that has a built in one, but then it would still work for the textarea fields)
4. the event is on the cell, and not the contents
5. 4 out of 5 browsers agree that this is the best way.. :)
6. Every other mouse event attachment has worked fine except the dblclick
Thanks for the suggestions though, thats what I would have told me too :)
Anyone have an alternative event capturing scheme for Safari?
jscheuer1
06-17-2006, 03:35 AM
After casting about on Google for a bit, this appears to be a bug. This page:
http://bugzilla.opendarwin.org/show_bug.cgi?id=7790
seems to have a solution, scroll down to see it, the top of the page is just the 'bug registration' part.
very nice pick.....
thanks a bunch
what was your google? I must have tried a zillion different searches and never came close
%$@&#%$^&#*$% khtmlDblclick ??!!!!! are they freaking kidding me??
just as good as M$ on the W3C Committee, voting for a standard event model, and then proceeding to implement the opposite.
but thanks again for a real tension tamer
s_mk
Will they ever learn..
jscheuer1
06-17-2006, 04:01 AM
After a few fruitless attempts, I used:
addEventListener Safari
for my search terms and one of the top results had a link to the bugzilla site about three quarters of the way down the page. I only bothered looking that far because, at the top, it was specifically the dblclick event that was at issue.
found an interesting Idea on a work around @
http://mikebulman.typepad.com/you_love_mike_bulman/2005/11/safari_addevent.html
down the bottom someone mentions checking the detail property of the event object passed
Could this work?
I dont have any Macs @ home, so if you or anyone could try it out, please post your findings :D
it would mean a little more overhead, but if it works, it works right?
djr33
06-17-2006, 10:34 AM
I use safari, but for complex JS, sometimes it's just better to realize that opening Mozilla will save many headaches.
It's javascript parser has a few differences than those of IE/FF, so it just will have weird things going on.
I'm sure with enough work you can make safari do it, but it might just not be worth it, depending on the need.
What do you want me to test? It's late, so I'm not gonna code an entire page from that article... didn't see anything on the page itself to "test".
jbrock
06-28-2006, 04:43 PM
I'm trying to make http://www.dynamicdrive.com/dynamicindex2/cmarquee2.htm work for Safari. Is there some line of code i can add to the js portion? If the scroll won't work, I'd be fine if i could just create scrollbars.:confused:
this is a novice talking, by the way.
djr33
06-29-2006, 07:01 AM
Wrong forum; you really should start a new thread and ask in Dynamic Drive Script Questions... at the top of the board.
As for the question, not just ignoring it, but I don't know, myself.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.