Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/391.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将javascript连接到URL_Javascript_Asp.net - Fatal编程技术网

将javascript连接到URL

将javascript连接到URL,javascript,asp.net,Javascript,Asp.net,下面是我拥有的URL我想用放置此代码的页面的URL更改href标记,我可以使用“window.location.href”获得该标记,但我想将其连接到href标记处的URL,我使用的是asp.net <iframe src="http://www.XYZ.com/plugins/like.php?href=<?php echo rawurlencode(get_permalink()); ?>&amp;layout=standard&amp;show_faces

下面是我拥有的URL我想用放置此代码的页面的URL更改href标记,我可以使用“window.location.href”获得该标记,但我想将其连接到href标记处的URL,我使用的是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>

//设置参数
var href=“”;
//获取当前位置
var current_location=window.location.href;
//设置iframe的源
document.getElementsByTagName('iframe')[0].src=current_location+'&href='+href;

//设置参数
var href=“”;
//获取当前位置
var current_location=window.location.href;
//设置iframe的源
document.getElementsByTagName('iframe')[0].src=current_location+'&href='+href;

如果我正确理解了您的问题,您应该能够将
href=
替换为:

href=<%= Request.Url.AbsoluteUri %>
href=
尽管为了防止XSS,您可能会比下载更糟糕,并确保对输出的URL进行编码:

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

如果我正确理解了您的问题,您应该能够将
href=
替换为:

href=<%= Request.Url.AbsoluteUri %>
href=
尽管为了防止XSS,您可能会比下载更糟糕,并确保对输出的URL进行编码:

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

您使用的是ASP.NET,但仍然使用PHP标记编码。它是哪一个?基本上,它是face book的一个PHP插件,XYZ url是face book,我想在其中添加我的asp.net页面链接,这个按钮将被放置在那里。您使用的是asp.net,但有PHP标记编码。它是哪一个?基本上,它是face book的一个PHP插件,XYZ url是face book,我想在其中添加我的asp.net页面链接,这个按钮将被放置在那里。你的解决方案也很棒。你的解决方案也很棒。