0

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?

2
  • 2
    You are using ASP.NET, and yet have PHP tag encoding. Which is it? Commented Apr 5, 2011 at 10:08
  • basically, it's a PHP plug in of face book, that XYZ url is face book where i want to add my asp.net page link where this button will be placed. Commented Apr 5, 2011 at 10:09

2 Answers 2

1

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) %>    
Sign up to request clarification or add additional context in comments.

Comments

1
<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>

1 Comment

your solution is amazing too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.