开发者

concatenate javascript to URL

Following is the URL I am having I want to change the href tag with开发者_如何学运维 the URL of the page where this code is placed, that I can get using "window.location.href" but I want to concatenate it to URL at the place of href tag, I am using asp.net

<iframe src="http://www.XYZ.com/plugins/like.php?href=<?php echo rawurlencode(get_permalink()); ?>&amp;layout=standard&amp;show_faces=true&amp;width=550&amp;action=like&amp;font=segoe+ui&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:550px; height:80px;" allowTransparency="true"></iframe>

I want to replace this href=<?php echo rawurlencode(get_permalink()); ?> with the current page's url, how can I achieve this please let me know?


<script type="text/javascript">
   // set the param
   var href="<?php echo rawurlencode(get_permalink()); ?>";
   // get current location
   var current_location = window.location.href;
   // set the source of the iframe
   document.getElementsByTagName('iframe')[0].src = current_location + '&href=' + href;
</script>


If I've understood your question properly, you should be able to replace href=<?php echo rawurlencode(get_permalink()); ?> with:

href=<%= Request.Url.AbsoluteUri %>

Although to guard against XSS you could do a lot worse than download the AntiXss library and make sure you encode the URL you're outputting:

href=<%= AntiXss.HtmlAttributeEncode(Request.Url.AbsoluteUri) %>    
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜