0

I use the following code for my sumbit to reddit button.

onclick="window.location = 'http://www.reddit.com/submit?url=<?php echo $url?>';

but the above won't work for cases where there a ' in $url

onclick="window.location = 'http://www.reddit.com/submit?url=http://vinejar.com/96-Don't-be-this-guy.html';

It is necessary to get $url there so the following won't help.

onclick="window.location = 'http://www.reddit.com/submit?url=' + encodeURIComponent(window.location);
user2726883
  • 161
  • 1
  • 3
  • 9

1 Answers1

1

You could encode your $url,for example:

onclick="window.location = 'http://www.reddit.com/submit?url=<?php echo urlencode($url) ?>';