I changed it this way;<br>
<pre><!DOCTYPE html>
<html>
        <head>
                <title>Loading a KML File</title>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
                
                <script type="text/javascript" src="OpenLayers.js"></script>
                
        <style>
        <!--
                html, body 
                {
                        width: 100%;
                        height: 100%;
                        margin: 0;
                        padding: 0;
                }
        -->
        </style>

        <script type="text/javascript">
        
        var filename = "";
        var map;
        var kml_layer;
                        
        function init() 
        {               
                var options =   {
                        minResolution: "auto",
                        minExtent: new OpenLayers.Bounds(-1, -1, 1, 1),
                        maxResolution: "auto",
                        maxExtent: new OpenLayers.Bounds(-180, -90, 180, 90),
                        controls: [
                        new OpenLayers.Control.LayerSwitcher({'ascending':false}),
                        new OpenLayers.Control.Navigation(),
                        new OpenLayers.Control.PanZoom(),
                        new OpenLayers.Control.KeyboardDefaults()
                        ],
                        numZoomLevels: 19,
                        units: 'm',
                        projection: new OpenLayers.Projection("EPSG:900913"),
                        displayProjection: new OpenLayers.Projection("EPSG:4326")
                };

                map = new OpenLayers.Map("map", options);

                var osm_layer = new OpenLayers.Layer.OSM();
                map.addLayer(osm_layer);

                kml_layer = new OpenLayers.Layer.Vector("KML", {
                        projection: map.displayProjection,
                        strategies: [new OpenLayers.Strategy.Fixed()],                  
                        protocol: new OpenLayers.Protocol.HTTP({
                                url: filename,
                                format: new OpenLayers.Format.KML({
                                        extractStyles: true,
                                        extractAttributes: true,
                                        maxDepth: 10
                                })
                        })
                });
                        
                map.addLayer(kml_layer);
                                
                map.zoomToMaxExtent();  
        }
        
        function AddLayer()
        {
                // get KML file
                filename = document.getElementById('theFile').value;

                if(filename == "")
                {
                        alert("Select KML file");
                }
                else
                {
                        kml_layer.refresh({url: filename });
                }                       
        }
                        
        </script>
        
        </head>
        
        <body onload="init()">
        
            <div id="top" style="width: 100%; height: 15pt; padding: 5px;">
                        <input type="file" id="theFile" size="100" />
                        &nbsp;&nbsp;
                        <input type="button" value="Show Markers" onClick="AddLayer()">
                </div>
                
                <div id="map" style="width: 100%; height: 100%;"></div>

        </body>
</html></pre><br><br>
Works excellent in Mozilla Firefox but again not in IE and Chrome.<br><br>
Error message in IE:<br>
<pre>Webpage error details
Message: Invalid argument.
Line: 747
Char: 153
Code: 0
URI: file:///D:/openlayers/OpenLayers.js
</pre><br><br>

This part from OpenLayers.js <br>
<pre>(a[1]||a[7])){b=parseInt(a[1],10)||0;var c=parseInt(a[2],10)-1||0,d=parseInt(a[3],10)||1;b=new Date(Date.UTC(b,c,d));if(c=a[7]){var d=parseInt(a[4],10),e=parseInt(a[5],10),f=parseFloat(a[6]),g=f|0,f=Math.round(1E3*(f-g));b.setUTCHours(d,e,g,f);"Z"!==c&&(c=parseInt(c,10),a=parseInt(a[8],10)||0,b=new Date(b.getTime()+-1E3*(60*60*c+</pre><br><br>
char: 153 starts at;<br>
<pre>e=parseInt(a[5...</pre><br><br>
What's going wrong ????

        
        
        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://osgeo-org.1560.n6.nabble.com/Problem-dynamic-loading-a-KML-file-refresh-tp5015133p5015436.html">Re: Problem dynamic loading a KML file (refresh)</a><br/>
Sent from the <a href="http://osgeo-org.1560.n6.nabble.com/OpenLayers-Users-f3910695.html">OpenLayers Users mailing list archive</a> at Nabble.com.<br/>