Results 1 to 10 of 10

Thread: Safari headaches :(

  1. #1
    Join Date
    Jun 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy 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( 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)
    Code:
    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

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jun 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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?

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Jun 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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..

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Jun 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    found an interesting Idea on a work around @
    http://mikebulman.typepad.com/you_lo..._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

    it would mean a little more overhead, but if it works, it works right?

  8. #8
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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".
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  9. #9
    Join Date
    Jun 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default scrolling for safari

    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.

    this is a novice talking, by the way.

  10. #10
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •