JeepFreak Posted July 25, 2008 Share Posted July 25, 2008 function slicky_links($dirname, $filename, $page) { $imgurl = "http://www.slicky.net/gallery.php?cmd=midsize&gallery=$dirname&image=$filename"; $linkurl = "http://www.slicky.net/gallery.php?gallery=$dirname&page=$page"; $htmlcode = '<a href=' . $linkurl . '><img src=' . $imgurl . '></a>'; echo "<a href=\"Javascript:copy('$htmlcode');\">HTML Code</a>"; } OK, so this function works well... It creates a link called "HTML Code" which copies the link code to my clipboard. An example of the copied text would look like this: <a href=http://www.slicky.net/gallery.php?gallery=sample/&page=1><img src=http://www.slicky.net/gallery.php?cmd=midsize&gallery=sample/&image=IMG_0722.jpg></a> There's only one problem... the syntax is wrong. I need it to insert quotes around the image source url and the link url. I can't get it to work... it just keeps breaking up the original link code Anybody know how to get it working? Thank you! Billy Link to comment https://forums.phpfreaks.com/topic/116650-this-should-be-challenging/ Share on other sites More sharing options...
discomatt Posted July 25, 2008 Share Posted July 25, 2008 the right way to do this would be to store $htmlcode in a javascript variable, and call Javascript:copy( yourJavaVar ); Link to comment https://forums.phpfreaks.com/topic/116650-this-should-be-challenging/#findComment-599772 Share on other sites More sharing options...
DeanWhitehouse Posted July 25, 2008 Share Posted July 25, 2008 change $htmlcode = '<a href=' . $linkurl . '><img src=' . $imgurl . '></a>'; to $htmlcode = '<a href="' . $linkurl . '"><img src="' . $imgurl . '"></a>'; Link to comment https://forums.phpfreaks.com/topic/116650-this-should-be-challenging/#findComment-599780 Share on other sites More sharing options...
discomatt Posted July 25, 2008 Share Posted July 25, 2008 change $htmlcode = '<a href=' . $linkurl . '><img src=' . $imgurl . '></a>'; to $htmlcode = '<a href="' . $linkurl . '"><img src="' . $imgurl . '"></a>'; Wont work well here echo "<a href=\"Javascript:copy('$htmlcode');\">HTML Code</a>"; You might want to try using entities? " ? I'm not comfortable enough with javascript to know whether this would work off-hand. Link to comment https://forums.phpfreaks.com/topic/116650-this-should-be-challenging/#findComment-599781 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.