javascript - Appending one URL to another as a link -
what trying (and failing miserably @ it) create link... , link should open specific page current page appended it. example... if user on page called www.bar.com , click link... go www.foo.com?link=www.bar.com
here sorry little attempt @ this...
<img src="#" id="link" target="_blank"> <script type="text/javascript"> window.onload = function(){ document.getelementbyid("link").href = 'http://www.foo.com?link='.window.location.tostring(); } </script>
i in php can not use php particular page. can please help?
edit: botched question cause added code here in middle of editing on accident. trying alter href code place specific image in place instead ...for example
<img src="#">
becomes...
<img src="http://www.bar.com?link=www.foo.com">
sorry ignorance.
it's best wrap img tag , change attribute : (and use + , not . chaining strings ! )
<a href="#" target="_blank" id="mylink"><img src="#" ></a> <script type="text/javascript"> window.onload = function(){ document.getelementbyid("mylink").href = 'http://www.foo.com?link='+ window.location.href.tostring(); } </script>
Comments
Post a Comment