Try taking var map out of the load function and making it a global variable.
<html> <head> <title>Test</title> <style type="text/css"> #map{ width:100%; height:600px; border:1px solid; } </style> <script src="http://openlayers.org/api/OpenLayers.js"></script> <script defer="defer" type="text/javascript"> var map function load(mode){ if (mode=="start"){ ... . . map = new OpenLayers.Map('map',options); var wms = new OpenLayers.Layer.WMS(... . . . map.addLayer(wms); map.zoomToMaxExtent(); //map.setCenter(new OpenLayers.LonLat(145,-40),8);//here would be know error! } else if (mode=="newPos"){ map.setCenter(new OpenLayers.LonLat(145,-40),8);//-->error: map is undefined! } } </script> </head> <body onload="load('start')"> <table width="100%" border="0"> <tr> <td colspan="2" height="100">TITEL</td> </tr> <tr> <td width="20%"> <input type="button" value="Go" onClick="load('newPos')"> </td> <td><div id="map"></div></td> </tr> </table> </body> </html> -- View this message in context: http://n2.nabble.com/problem-with-map-setCenter-tp4779851p4779944.html Sent from the OpenLayers Users mailing list archive at Nabble.com. _______________________________________________ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users