views:

296

answers:

3

I've stepped into a new position and am tasked with cleaning up pre-existing code. I will be posting a Javascript function for building hotel reservations by using a base URL and then carrying over variables to the other site.

More clearly, this function allows your to access Site A and search for hotel reservations on Site B. The function makes this even clearer.

function buildReservationURL(){
  var site = "http://ach.travel.yahoo.net/hotel/HotelCobrand.do?smls=Y&Service=YHOE&.intl=us&.resform=YahooHotelsCity&";


 <!-- Variables Are Defined Here from Form Values //-->


  var finishedURL = site + "city=" + cityname + "&state=" + statename + "&dateLeavingDay=" + inDay + "&dateReturningDay=" + outDay + "&adults=" + adults + "&source=YX&distance=&hotelChain=&searchMode=city&cityCountryCode=us&&dateLeavingMonth=" + inMonth + "&dateReturningMonth=" + outMonth;
  NewWindow(finishedURL,'Yahoo Travel','780','580','yes','no','1');
}

However, I am receiving an error in IE that gives zero information. The error occurs prior to a window being created so I feel the error would reside somewhere in the function where it is created and the URL is built. This does work fine in FireFox. Any ideas?

+3  A: 

Use IE8's debugger and use "break on error." If it doesn't break in IE8, turn on compatibility view. That uses the IE7 javascript engine while still giving you IE8 debugging facilities.

Stefan Kendall
+1  A: 
function NewWindow(mypage,myname,w,h,scroll, menu, res){
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height=' + h + ',width=' + w + ',top=' + wint + ',left=' + winl + ',scrollbars=' + scroll + 
', resizable=' + res + ', location=no, directories=no, status=yes, menubar=' + menu;
win = window.open(mypage,myname,winprops);
if(parseInt(navigator.appVersion) > 3){
    win.window.focus();
}

}

Slevin
+2  A: 

Could it be you're using a version of IE that doesn't support spaces in the window name? ("Yahoo Travel" in your example.)

Pablo
That was it. Thank you.
Slevin
AFAIK - this affects all versions of IE (e.g. ...,6,7,8)
scunliffe
Had the same error, after removing the Spaces in the window name, the problem was solved. Thanks
Roland