Problems with Safari

Last post 03-01-2006, 12:03 PM by rokinroj. 1 replies.
Sort Posts: Previous Next
  •  02-24-2006, 3:07 PM 16414

    Problems with Safari

    I am using javascript in an asp.net 2.0 site to attach events (or event listeners) to the 3 tab images in the editor (Normal, HTML, Preview).  The script is called in this way:

    <body onload='CE_attachEvent()'>

    function CE_attachEvent()
    {
         // get the cute editor instance
         var editor = document.getElementById('<%=Editor.ClientID%>');
        
        //get all of the images on the editor
        if (editor.all)
         {
              var images=editor.all.tags("IMG");
         }
         else
         {
              var images = editor.getElementsByTagName('IMG');
         }
     
        var len=images.length;
        for(var i=0;i<len;i++)
        {
             var img=imagesIdea [I];
             var imgsrc = img.src.toString();
            //if the image is one of the tab images, call the addEvent function
             if(imgsrc.indexOf('design.gif')!=-1 | imgsrc.indexOf('htmlview.gif')!=-1 | imgsrc.indexOf('preview.gif')!=-1)
             {
                 addEvent(img,'click',HandleIEChange);
             }
         }
    }
     
    function addEvent(obj,type, fn)
    {
        //if browser is IE or supports the IE attachEvent
        if (obj.attachEvent)
        { 
             obj['e'+type+fn] = fn; 
             obj[type+fn] = function(){obj['e'+type+fn]( window.event );} 
             obj.attachEvent('on'+type, obj[type+fn] );
        }
        //non IE browsers
        else
        {
             obj.addEventListener(type,HandleNonIEChange(obj.title),false);
        }         
    }
     
    This script works perfectly in IE on the PC using the attachEvent method and in Firefox on the PC using the addEventListener method.  Everything I've found says Safari supports the addEventListener method, but when this same page loads in Safari there are several issues.  First is there is no content on any tab as there is in all the other browsers.  Secondly, I am unable to type in the Normal view.  I must go to the HTML tab, type something, then I can go back to the Normal and I can type. 
    The HandleIEChange, and HandleNonIE change methods which call a server side method are listed below.
     
    function HandleIEChange()
    {
         // get the cute editor instance
          var editor = document.getElementById('<%=Editor.ClientID%>');
          // get the current tab  
          var tab = editor.GetActiveTab();
          // call serverside event via ajax
          var response = EditContent.GetHtml(tab);
          // set the html on the editor
          editor.setHTML(response.value);
    }
     
    function HandleNonIEChange(tabName)
    {
        // get the cute editor instance
        var editor = document.getElementById('<%=Editor.ClientID%>');    
        // get the current tab
        var tab;
        if(tabName=='Normal')
        {
             tab='Edit';
        }
        else if(tabName=='HTML')
        {
             tab='Code';
        }
        else if(tabName=='Preview')
        {
             tab='View';
        }
        // call serverside event via ajax
        var response = EditContent.GetHtml(tab);          
        // set the html on the editor                      
        editor.setHTML(response.value);   
    }
     
    Can anyone see any reason why this won't work on the Mac the way it does on the PC?
     
    Thanks
    Roger H.
  •  03-01-2006, 12:03 PM 16562 in reply to 16414

    Re: Problems with Safari

    Any help would be appreciated as this is for two of your paying customers.
     
    Thanks
View as RSS news feed in XML