encodeURIComponent pass to 2nd parameter help
Posted: Wed Nov 11, 2009 3:00 pm
I am trying to write a script that outputs the following url
<a href="http://www.socialsite.com/cgi/add?title ... =IMAGE_URL">
<img src="http://cdn.socialsite.com/rsrc/img/my_image.png">
</a>
The code below outputs a the url below. The problem is (in red text). It is passing the first parameter. I need it to pass tthe second (item image) image parameter. What do I need to change to pass the first image and output the item image url (2nd)
<a href="http://www.socialsite.com/cgi/add?title ... RL&imgurl=img/my_image.png">
Thank you for your help
<a href="http://www.socialsite.com/cgi/add?title ... =IMAGE_URL">
<img src="http://cdn.socialsite.com/rsrc/img/my_image.png">
</a>
The code below outputs a the url below. The problem is (in red text). It is passing the first parameter. I need it to pass tthe second (item image) image parameter. What do I need to change to pass the first image and output the item image url (2nd)
<a href="http://www.socialsite.com/cgi/add?title ... RL&imgurl=img/my_image.png">
Code: Select all
<a href="#" onclick="handleImageClick( 'http://cdn.socialsite.com/rsrc/img/my_image.png' ); return false;" target="_blank">
<img src="http://cdn.socialsite.com/rsrc/img/favicon.png">
</a>
<script type="text/javascript">
function handleImageClick( imgUrl ) {
var path = 'http://www.socialsite.com/cgi/add.php?';
path += 'title=' + encodeURIComponent( document.title );
path += '&url=' + encodeURIComponent ( document.location.href );
path += '&imgurl=' + encodeURIComponent ( imgUrl );
window.open(path);
}
</script>