Changeset 622

Show
Ignore:
Timestamp:
2007-08-03 12:52:47 (18 months ago)
Author:
fredck
Message:

IE was throwing "Unspecified error" when opening _samples/default.html. Added a try/catch to avoid it.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor/trunk/editor/_source/classes/fckdomrange_ie.js

    r618 r622  
    135135FCKDomRange.prototype._GetSelectionMarkerTag = function( toStart ) 
    136136{ 
     137        var doc = this.Window.document 
     138        var selection = doc.selection ; 
     139 
    137140        // Get a range for the start boundary. 
    138         var oRange = this.Window.document.selection.createRange() ; 
     141        var oRange ; 
     142 
     143        // IE may throw an "unspecified error" on some cases (it happened when 
     144        // loading _samples/default.html), so try/catch. 
     145        try 
     146        { 
     147                oRange = selection.createRange() ; 
     148        } 
     149        catch (e) 
     150        { 
     151                return null ; 
     152        } 
     153 
    139154        oRange.collapse( toStart === true ) ; 
    140155 
     
    142157        // This is known to happen when the editor window has not been selected before (See #933). 
    143158        // We need to avoid that. 
    144         if (oRange.parentElement().document != this.Window.document) 
     159        if ( oRange.parentElement().document != doc ) 
    145160                return null; 
    146161 
     
    148163        var sMarkerId = 'fck_dom_range_temp_' + (new Date()).valueOf() + '_' + Math.floor(Math.random()*1000) ; 
    149164        oRange.pasteHTML( '<span id="' + sMarkerId + '"></span>' ) ; 
    150         return this.Window.document.getElementById( sMarkerId ) ; 
     165        return doc.getElementById( sMarkerId ) ; 
    151166} 
    152167