在尝试在问号后追加时,表单会出错

时间:2021-08-31 09:38:36

I'm trying to send visitors to http://www.facebook.com/plugins/comments.php?href=http://google.com?c

我正在尝试将访问者发送到http://www.facebook.com/plugins/comments.php?href=http://google.com?c

Gives the error

给出错误

The comments plugin requires an href parameter.

评论插件需要一个href参数。

This part is rendered correctly: http://www.facebook.com/plugins/comments.php

这部分是正确呈现:http://www.facebook.com/plugins/comments.php

but the stuff after the question mark fails to be included

但问号后面的内容未能包括在内

<script>
function go(){
    var uri = 'http://www.facebook.com/plugins/comments.php' 
        + encodeURI('?href=http://google.com?c');

    window.frames[0].document.body.innerHTML = 
        '<form target="_parent" method="get" action="' 
        + uri 
        + '"></form>';
    window.frames[0].document.forms[0].submit();
}    
</script>
<iframe onload="window.setTimeout('go()', 99)" src="about:blank" style="visibility:hidden"> </iframe>?

2 个解决方案

#1


1  

Change to:

var uri = 'http://www.facebook.com/plugins/comments.php?' 
    + encodeURIComponent('href=http://google.com?c');

If you encode the first ? it no longer serves to separate the URL from its parameters.

如果您编码第一个?它不再用于将URL与其参数分开。

#2


0  

Only the keys and value of the query should be encoded, not the ?,& or = as these are the characters that structure the query.

只应编码查询的键和值,而不是?,&或=,因为这些是构成查询的字符。

var uri = 'http://www.facebook.com/plugins/comments.php?href=' 
    + encodeURIComponent('http://google.com?c');

#1


1  

Change to:

var uri = 'http://www.facebook.com/plugins/comments.php?' 
    + encodeURIComponent('href=http://google.com?c');

If you encode the first ? it no longer serves to separate the URL from its parameters.

如果您编码第一个?它不再用于将URL与其参数分开。

#2


0  

Only the keys and value of the query should be encoded, not the ?,& or = as these are the characters that structure the query.

只应编码查询的键和值,而不是?,&或=,因为这些是构成查询的字符。

var uri = 'http://www.facebook.com/plugins/comments.php?href=' 
    + encodeURIComponent('http://google.com?c');