By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,051 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

window.location not working in safari

mikek12004
100+
P: 200
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?
Oct 13 '08 #1
Share this Question
Share on Google+
3 Replies


acoder
Expert Mod 15k+
P: 16,027
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.
Oct 13 '08 #2

mikek12004
100+
P: 200
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
Oct 15 '08 #3

acoder
Expert Mod 15k+
P: 16,027
Glad to hear that you got it working.
Oct 15 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.