Scooby08 Posted April 7, 2011 Share Posted April 7, 2011 This works in all browsers but IE.. Would anybody happen to know of a work around? var URL = window.location.href.toString(); if (URL == 'http://www.host.com/') { $('#audio').show(); } else { $('#audio').hide(); } Thank you.. Link to comment https://forums.phpfreaks.com/topic/233001-anybody-know-of-an-ie-tostring-work-around-for-this/ Share on other sites More sharing options...
Adam Posted April 7, 2011 Share Posted April 7, 2011 window.location.href is a string, you shouldn't use .toString() either way. Link to comment https://forums.phpfreaks.com/topic/233001-anybody-know-of-an-ie-tostring-work-around-for-this/#findComment-1198344 Share on other sites More sharing options...
Scooby08 Posted April 7, 2011 Author Share Posted April 7, 2011 Ok.. If that's the case then I'm not understanding the issue here then.. The below still does not work in IE.. Works in all other browsers.. var URL = window.location.href; if (URL == 'http://www.host.com/') { $('#audio').show(); } else { $('#audio').hide(); } Link to comment https://forums.phpfreaks.com/topic/233001-anybody-know-of-an-ie-tostring-work-around-for-this/#findComment-1198349 Share on other sites More sharing options...
Adam Posted April 7, 2011 Share Posted April 7, 2011 Try checking for only a portion of the string - IE probably returns something slightly different (in true IE fashion) to other browsers... if (URL.indexOf('host.com') != -1) { Link to comment https://forums.phpfreaks.com/topic/233001-anybody-know-of-an-ie-tostring-work-around-for-this/#findComment-1198353 Share on other sites More sharing options...
Scooby08 Posted April 7, 2011 Author Share Posted April 7, 2011 Well the deal is I'm just wanting to show the audio div on the home page.. So if var URL = 'http://www.host.com/contact/' the audio should not show.. Link to comment https://forums.phpfreaks.com/topic/233001-anybody-know-of-an-ie-tostring-work-around-for-this/#findComment-1198364 Share on other sites More sharing options...
Adam Posted April 7, 2011 Share Posted April 7, 2011 Then you could use: if (URL.match(/host\.com\/?$/)) That would match the URL ending with host.com (and an optional slash on the end). Link to comment https://forums.phpfreaks.com/topic/233001-anybody-know-of-an-ie-tostring-work-around-for-this/#findComment-1198367 Share on other sites More sharing options...
Scooby08 Posted April 7, 2011 Author Share Posted April 7, 2011 Thanks a ton.. That helped get me going in the right direction.. Link to comment https://forums.phpfreaks.com/topic/233001-anybody-know-of-an-ie-tostring-work-around-for-this/#findComment-1198420 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.