www.webdeveloper.com
Results 1 to 6 of 6

Thread: Control-clicks in Opera are weird

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    At the corner of WALK and DONT WALK
    Posts
    1,733

    Control-clicks in Opera are weird

    I have a set of scripts that run if I control-shift-click an element. In Opera, this mostly works fine--UNLESS I control-shift-click an image that's not a child of a link. When I do, Opera tries to save the image. Control-clicking and alt-control-clicking do the same thing. How do I get around this?

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,656
    why wouldn't you investigate it on Opera forums?

  3. #3
    Join Date
    Sep 2004
    Location
    At the corner of WALK and DONT WALK
    Posts
    1,733
    Because I'm looking for a JavaScript solution in a JavaScript forum, and I'd hoped someone here might have an answer/

  4. #4
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,656
    then show your scripts to people to let them see what you are talking about or is it a kind of puzzle?

  5. #5
    Join Date
    Sep 2004
    Location
    At the corner of WALK and DONT WALK
    Posts
    1,733
    Right. Sorry about that.

    Here's the script that assigns click events.

    PHP Code:
    function adjustIMGLink($evnt$elem){
        var 
    $a_el $elem.orig_el.parentNode;
        if((
    $elem.orig_el.nodeName.toLowerCase()  == 'img') && ($a_el.nodeName.toLowerCase() =='a')){
            if(!
    $a_el.hasAttribute('j_href')){$a_el.setAttribute('j_href'$a_el.getAttribute('href'));}
            if((
    $evnt.shiftKey) && (($evnt.ctrlKey && !$evnt.altKey) || (!$evnt.ctrlKey && $evnt.altKey))){$a_el.removeAttribute('href');} 
                else {
    $a_el.setAttribute('href'$a_el.getAttribute('j_href'));}
        }
    }

    function 
    checkClick($evnt$elem){
        if(
    $evnt.ctrlKey && $evnt.shiftKey && !$evnt.altKey){
            
    addBreak($evnt$elem);
        }
        if(
    $evnt.altKey && $evnt.shiftKey && !$evnt.ctrlKey && $elem.orig_el.nodeName.toLowerCase()  == 'img'){
            
    SizeCSS($evnt$elem);
        }
    }
    var 
    $el_names = new Array(
        
    'img',
        
    'div',
        
    'h2',
        
    'h3',
        
    'h4',
        
    'h5',
        
    'h6',
        
    'p',
        
    'li',
        
    'dt',
        
    'tr',
        
    'caption'
    );
    var 
    $break_els = new Array();

    for(var 
    $i 0$i $el_names.length$i++){
        var 
    $el_list document.getElementsByTagName($el_names[$i]);
        for(var 
    $ii 0$ii $el_list.length$ii++){
            if(
                (
    $el_list[$ii].nodeName.toLowerCase() != 'div') ||
                (
                    (
    $el_list[$ii].nodeName.toLowerCase()  == 'div') && 
                    (
    $el_list[$ii].hasAttribute('class')) && 
                    (
                        (/
    ln[0-9][0-9]/.test(SlctrClass($el_list[$ii])))||
                        (/
    samp[0-9]/.test(SlctrClass($el_list[$ii])))||
                        (
    SlctrClass($el_list[$ii]) == 'code_header')||
                        (
    SlctrClass($el_list[$ii]) == 'code_subheader')||
                        (/
    subh[0-9]/.test(SlctrClass($el_list[$ii])))
                    )
                )
            ){
                
    $break_els.push(GetSelector($el_list[$ii]));
            }
        }
    }

    for(var 
    $i 0$i $break_els.length$i++){
        (function(
    num) {
            
    $break_els[num].orig_el.addEventListener('mousedown',function(e) {adjustIMGLink(e,$break_els[num]); } ,false); 
            
    $break_els[num].orig_el.addEventListener('click',function(e) {checkClick(e,$break_els[num]); } ,false); 
        }(
    $i));


  6. #6
    Join Date
    Sep 2004
    Location
    At the corner of WALK and DONT WALK
    Posts
    1,733
    Oh, and for good measure, a link to one of the pages in question:

    http://mrinitialman.com/Books/HTML/C.../JS-Style.html

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles