Page 1 of 1

Passing image url parameter

Posted: Fri May 14, 2010 10:16 am
by avoosh
Hi,
I am trying to make this static code into dynamic. I can not get it to work with the title parameter. It does pass the 2 (link) parameter but only the root link. The 3rd parameter is broke. I would appreciate anyone's help


Static
<a href="http://www.polyvore.com/cgi/add?title=T ... =IMAGE_URL">
<img src="http://cdn.polyvore.com/rsrc/img/favicon.png">
</a>

Code: Select all

     
  
  <a href="#" onclick="handleImageClick( 'http://www.polyvore.com/cgi/add?title=title&url=url&imgurl=imgurl' ); return false;"  target="_blank">
<img src="http://cdn.polyvore.com/rsrc/img/favicon.png" border="0">
</a>
 
<script type="text/javascript">
function handleImageClick( imgUrl ) {
  var path = 'http://www.polyvore.com/cgi/add?';
  path += 'title=' + encodeURIComponent( document.title );
  path += '&url=' + encodeURIComponent ( document.location.href );
  path += '&imgurl=' + encodeURIComponent ( imgUrl );
  window.open(path);
 }
 </script>

Re: Passing image url parameter

Posted: Fri May 14, 2010 3:02 pm
by ell0bo
What is the resulting path that get generated? The code looks correct, but if I can see what the result is perhaps I can have a better idea.

I do notice you're passing in "http://www.polyvore.com/cgi/add?title=t ... url=imgurl" instead of "http://cdn.polyvore.com/rsrc/img/favicon.png" to the function.

Re: Passing image url parameter

Posted: Fri May 14, 2010 11:22 pm
by avoosh
Hi, thanks for answering, the resulting output is

http://www.polyvore.com/cgi/add?title=A ... l%3Dimgurl

I'm really looking forward to getting this figured out.

thanks

Re: Passing image url parameter

Posted: Sat May 15, 2010 1:56 pm
by ell0bo
Your code is doing exactly what you wrote it to do. You are passing in 'http://www.polyvore.com/cgi/add?title=t ... url=imgurl' to the function and it's being appended into the imgurl part of the URL.