简体   繁体   English

如何更改此输入的值?

[英]How can I change this input's value?

I want to change the input of a text field that stores the subject line in the Outlook Web App using JavaScript: 我想更改使用JavaScript将主题行存储在Outlook Web App中的文本字段的输入:

在此处输入图片说明

This subject text field is defined as: 该主题文本字段定义为:

<input tabindex="0" class="_f_ql _f_rl textbox allowTextSelection placeholderText" role="textbox" aria-labelledby="MailCompose.SubjectWellLabel" autoid="_f_B2">

I have tried the following using my JavaScript code: 我已经使用JavaScript代码尝试了以下方法:

textFieldElement.value = "Example";
textFieldElement.innerHTML = "Example";
textFieldElement.innerText = "Example";

These work to set the value as far as the user interface is concerned: 这些工作用于设置有关用户界面的值:

在此处输入图片说明

But they don't modify the "real" value of the subject that gets posted when you hit Send. 但是,当您单击“发送”时,它们不会修改发布的主题的“真实”值。 Once you hit the Send button, the subject takes on no value (and shows up as (no subject) in an email). 按下“发送”按钮后,主题将没有任何价值(并在电子邮件中显示为(no subject) )。 I can see from the POST request that unless I manually click on the element, focus it, and manually type in what I want it to display, physically with the keyboard, it won't send the subject argument in its JSON object. 从POST请求中可以看到,除非手动单击元素,将其聚焦,然后手动输入要显示的内容(实际上是使用键盘),否则它不会在其JSON对象中发送subject参数。

在此处输入图片说明

How can I modify the "real" subject value that this control is expected to handle? 如何修改该控件应处理的“真实”主题值? I'm guessing this is an MVC control or some other type of ASP.NET control...and I am trying to modify the .aspx page, with JavaScript, to edit this value. 我猜想这是一个MVC控件或某种其他类型的ASP.NET控件...并且我正在尝试使用JavaScript修改.aspx页以编辑此值。

------------------------------------------------------------------------------------------------------------------------------------------------ -------------------------------------------------- -------------------------------------------------- --------------------------------------------

Edit : I have only been able to set the subject line in one specific case. 编辑 :我只能在一种特定情况下设置主题行。 First, I need to physically click on the subject element. 首先,我需要物理上单击主题元素。 I've noticed this has a strange behavior of setting the class on this element from this: 我已经注意到,在此元素上设置类的行为很奇怪:

<input class="_f_ql _f_rl textbox allowTextSelection placeholderText" autoid="_f_B2" role="textbox" tabindex="0" aria-labelledby="MailCompose.SubjectWellLabel">

To this: 对此:

<input class="_f_ql _f_rl textbox allowTextSelection" autoid="_f_B2" role="textbox" tabindex="0" aria-labelledby="MailCompose.SubjectWellLabel" maxlength="255">

Once it is in the non-placeholderText state with maxlength = "255", I am able to successfully change the innerText on it using textFieldElement.innerText = "Example"; 一旦它处于maxlength =“ 255”的non-placeholderText状态,我就可以使用textFieldElement.innerText = "Example";成功更改它的innerText textFieldElement.innerText = "Example"; , and on submit, this gets sent correctly. ,并在提交后正确发送。

However, I cannot assume that the Subject element will ever be clicked, so I must work with the placeholderText version of the subject element first and somehow get it to reproduce this behavior where it goes into the other state. 但是,我不能假定Subject元素会被单击,因此我必须首先使用subject元素的placeholderText版本,并以某种方式使其在进入其他状态时重现此行为。 So far, I have tried the following without success: 到目前为止,我已经尝试了以下方法,但没有成功:

  • Focusing the placeholderText subject element, then setting its innerText. 重点关注placeholderText主题元素,然后设置其innerText。
  • Changing the placeholderText subject element's attributes to match the non-placeholderText version of it, then setting its innerText. 更改placeholderText主题元素的属性以匹配其非placeholderText版本,然后设置其innerText。

http://msdn.microsoft.com/en-us/library/office/fp161027(v=office.1501401).aspx http://msdn.microsoft.com/en-us/library/office/fp161027(v=office.1501401).aspx

Looks like you need to use 看起来您需要使用

Office.context.mailbox.item.subject to set the subject. Office.context.mailbox.item.subject设置主题。 Outlook uses an API, so you need to use the API methods. Outlook使用API​​,因此您需要使用API​​方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM