升级添加一个字段链接的JavaScript [英] upgrading javascript that adds a link to a field

查看:103
本文介绍了升级添加一个字段链接的JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将销售阶段字段标签更改为超链接以弹出新的浏览器窗口。

目前我有一个表单与销售阶段字段有一个下拉列表::

Currently I have a form with a Sales Stage field that has a drop down::

底层HTML:

<td title="Select the sales process stage for the opportunity to indicate the probability of closing the opportunity." class="ms-crm-ReadField-Normal ms-crm-FieldLabel-LeftAlign" id="salesstagecode_c"><span class="ms-crm-InlineEditLabel"><span class="ms-crm-InlineEditLabelText" style="text-align: left; max-width: 115px;">Sales Stage</span><div class="ms-crm-Inline-GradientMask" style="display: none;">
</div></span></td>

或更好的格式:

img src =https://i.stack.imgur.com/xvj4R.pngalt =enter image description here>

以前使用的函数在旧版本的表单中工作:

The function that I used previously worked on an older version of the form:

function csjs_AddHyperlinkToLabel(sFieldId, sURL, sWindowOptions) {
    var sCurrentLabel = $("label[for='" + sFieldId + "']").html();
    $("label[for='" + sFieldId + "']").html("<a href=\"#\" onclick=\"window.open('" + sURL + "', null, '" + sWindowOptions + "'); return false;\" style=\"cursor:hand; color:blue; text-decoration:underline;\">" + sCurrentLabel + "</a>");
} 

上面的函数在带有以下html ::

the function above worked on a form with the following html::

需要更改JavaScript才能将Sales Stage字段标签更改为超链接以弹出新的浏览器窗口?

虽然我非常感谢一个解决方案,我正在寻找如何完成这一点的指导。感谢您的关注和时间。

Though I'd be very grateful for a solution, I'm looking for guidance on how to accomplish this. Thank you for your attention and time.

不幸的是,下面的解决方案无效。我通过调试器运行,这是我获得的 http://screencast.com/t/fT6tHvXZzvc

Unfortunately, the solutions below did not work. I ran this through the debugger and here's what I got http://screencast.com/t/fT6tHvXZzvc

此处的问题是我们将salesstagecode传递给此功能:

The issue here is that we are passing "salesstagecode" to this function:

csjs_AddHyperlinkToLabel("salesstagecode", sPageURL, sWindowFeatures);

,这证明是NULL:

var sCurrentLabel = $("label[for='" + sFieldId + "']").html();

*


问题是Microsoft更改了表单的呈现方式,
渲染页面的HTML将不再与
函数的写入方式一起工作。标签现在位于span标签中,而不是
标签标签。我不知道是否有办法识别这个跨度,并且
更改内容以具有新的HTML以使文本链接。

The issue is that Microsoft changed the way the forms are rendered and the HTML of the rendered page will no longer work with the way the function was written. The label is now in a span tag instead of a label tag. I don't know if there is a way to identify that span and change the contents to have new HTML to make the text link.

*

如何更新跨标签?

推荐答案

简单:

更改

 .... onclick=\"window.open('" + sURL + "', null, '" ....

to

 .... onclick=\"window.open('" + sURL + "', '_blank', '"  ....

这篇关于升级添加一个字段链接的JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆