Connecting Tech Pros Worldwide Forums | Help | Site Map

window.location not working in safari

mikek12004's Avatar
Familiar Sight
 
Join Date: Sep 2008
Location: Athens, Greece
Posts: 187
#1: Oct 13 '08
I have a itunes link for a song, when the user clicks the link I want first to record this in a database and then redirect him to itunes so I used AJAX, the link is
Expand|Select|Wrap|Line Numbers
  1. <a name='1<?php echo $aa; ?>' href='#1<?php echo $aa;?>'  onClick="rec_song(<?php $skwd=$songs_array[$aa]['code']; echo "'$skwd'";?>,<?php echo "'$kwd'";?>)">
  2.  
In the same file I include a js file which calls a php file to make the record in the database and then uses
Expand|Select|Wrap|Line Numbers
  1. function stateChanged() 
  2.     if (xmlHttp.readyState==4)
  3.     { 
  4.     var itunesurl=xmlHttp.responseText;
  5.     window.location=itunesurl;
  6.  
  7.     }
  8. }
  9.  
I retrieve the url for the particular album from my php file and echo it then I use the above function to redirect him. Works fine in all browsers except safariwhere if the link is e.g.
http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewAlbum?id=272152906&s=14344
it makes it
/generalm/demo/http://phobos.apple.com/WebObjects/MZStore.woa/wa/view
and says not found (all the files are in a directory /generalm/demo/)
any ideas?

acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Oct 13 '08

re: window.location not working in safari


It shouldn't do that. I don't know if it's a Safari bug, but try setting window.location.href instead to see if it makes a difference.
mikek12004's Avatar
Familiar Sight
 
Join Date: Sep 2008
Location: Athens, Greece
Posts: 187
#3: Oct 15 '08

re: window.location not working in safari


OK solved it, for some reason when I took the url to use in href it had one line space before the URL and several after (the original url in PHP had 81 char and the one I got and measured in javascript got 90!) removed the white spaces and all OK
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#4: Oct 15 '08

re: window.location not working in safari


Glad to hear that you got it working.
Reply