0

I'd like to help the visitors to my site to fill out a form on the other site (beyond control) using the data, generated on my site.

It would be possible to use a bookmarklet to post the data to the form while the user is on my site, but the form is some clicks behind the authentication. Considering that a bookmarklet may read only what's been stored (cookie, session, storage) while on the current site, it is not possible to use the bookmarklet on the other site to fill out the form with data, stored while on my site.

Please, suggest any javascript, client-side solutions of this. Like a bookmarklet or something similar.

Thank you.

4

1 回答 1

0

使用书签我会说你在正确的轨道上,但使用动态的。例如:

function makeBookmarklet(){
    var elt=document.createElement('a');
    var hrefString='';
    for(var k=0;k<arguments.length;k++){
        hrefString+=' document.getElementById("'+arguments[k].id+'").value="'+arguments[k].value+'";';
    }
    elt.href=hrefString;
    return elt;
}

然后你会调用那个函数,每个参数都应该是一个带有idandvalue属性的对象。id应该是要自动填写的字段的 id 。value应该是插入该字段的值。它返回一个元素,因此将其放在文档中的某个位置并告诉用户将其拖到书签栏中,然后在其他站点上单击它。为了更清楚起见,您可以这样称呼它:

aElt=makeBookmarklet({id:'username',value:document.getElementById('username').value},{id:'othercrap',value:'fixedvalue'});
于 2013-11-18T01:06:08.543 回答