Forum Moderators: open
<script language="Javascript1.2">document.write('<a href="javascript:void(0)" onclick=window.open("/js/recommend.php?loc=http://www.site.net/news/0001&story=Large elephant loose","","height=280,width=260,top=150,left=200,toolbar=no,menubar=no,location=no,status=no,resizable=1"); title="Recommend this to a friend">Send to a Friend (testing)</a>');</script>
What this is meant to be is a simple "send to a friend" script. This code generates a link to the script (which works just fine). I'm using variables in the address-line to be used later - that's the 'loc' there, and the 'story'.
The problem is that Javascript doesn't seem to like those spaces in the 'story' variable. Php doesn't care, but Javascript does. Is there any reason for this or a way around it? Thanks.
What purpose does void(0); serve?
If all you want to do is open a new window, use the target attribute with the link and use the js function escape to perform the encoding.
If the url is known when the page is served, surely the link should be created in php without any need for javascript.
Kaled.