English 中文(简体)
如何加密提交行动发送的表格数据信息
原标题:How to encrypt the formdata message that is sent with the submit action

I have this code that sets attribute "onclick" to all submit buttons to call a certain function. The userscript is going to run on social network sites(Facebook) and encrypt the messages the users send. So I want on the click event to pause the default action, access the message that it sends somehow (I guess with formData ), run encrypt function on the text message and continue the submit action with the message sent encrypted. So here is the script:

$( textarea , window.content.document)
.closest( form )
.find( input[type=submit] )
.attr("onclick","dont();");

function dont(){
//access formData sent with the submit action and encrypt the message
};
问题回答

它认为你可能没有返回。 在浮标注中,在职能不停止行动之前不会返回。

$( textarea , window.content.document)
.closest( form )
.find( input[type=submit] )
.attr("onclick","return dont();");

function dont(){
//access formData sent with the submit action and encrypt the message
//be sure to return true or false depending on if you want the action submitted
};

如下文所示,你不能将浮标功能放在提交纽芬兰州,而是可以直接界定收集和加密形式数据的功能。

<form name="sampleForm" method="post" onsubmit="return dont()" enctype="multipart/form-data" action="someurl">


function dont()
{
    //code to access the form data and encrypt

    if(error)
       return false;  //Stops the submission of the form
    else
      return true;

}

简言之,它没有提交(投入类型=提交书)而是规定了立数功能,如下文所示:

<input type="button" value="submit" onclick="dont()" />

function dont()
{
    //code to access the form data and encrypt

    if(error)
       alert("Failed")  //Stops the submission of the form
    else
      document.forms[0].submit();

}

希望这一帮助。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签