Your code contains:map.infoWindow.resize(415,230);
map.infoWindow.show(evt.screenPoint, esri.dijit.InfoWindow.ANCHOR_UPPERRIGHT);
so it looks like you always want to show the infoWindow to the upper-right of the evt.screenPoint (the location the user clicks) and have it appear at this fixed size.You can use this logic to calculate whether the infoWindow will fit at a given point:function executeIdentifyTask(evt) {
map.graphics.clear();
//Set the infoWindow to open at the top right of the point at all times
map.infoWindow.setFixedAnchor(esri.dijit.InfoWindow.ANCHOR_UPPERRIGHT);
//Determine the upper right, and center, coordinates of the map
var maxPoint = new esri.geometry.Point(map.extent.xmax, map.extent.ymax)
var centerPoint = new esri.geometry.Point(map.extent.getCenter());
//Convert these to screen coordinates
var maxPointScreen = map.toScreen(maxPoint);
var centerPointScreen = map.toScreen(centerPoint);
//Subtract the size of the infoWindow, including a buffer.
//This will show whether the infoWindow would spill out of the current view.
var xDiff = Math.abs(maxPointScreen.x - evt.screenPoint.x) - 435;
var yDiff = Math.abs(maxPointScreen.y - evt.screenPoint.y) - 285;
//If required, recalculate a new centerpoint which accounts for the infoWindow
if (xDiff < 0) {centerPointScreen.x -= xDiff;}
if (yDiff < 0) {centerPointScreen.y += yDiff;}
//Pan the map to the new centerpoint (in Map coordinates)
centerPoint = map.toMap(centerPointScreen);
map.centerAt(centerPoint);
//Display the infoWindow at the original point clicked
map.infoWindow.show(evt.screenPoint, esri.dijit.InfoWindow.ANCHOR_UPPERRIGHT);
Steve