我需要将它变成java中的字符串:
<script type="text/javascript">document.write("<img src=\"UpArrow.png\" /> \"); </script>
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?我一直在努力,结果就像这样......
return "<script type=\"text/javascript\">document.write(\"<img src=\"UpArrow.png\" /> \"); </script>";
Run Code Online (Sandbox Code Playgroud)
哪个不起作用,因为我需要在UpArrow.png之前和之后双重转义引号.因为它需要在javascript中转义而不是在java中转义.
我将公司名称传递给onclick事件.一些公司名称中包含撇号.我将'.Replace("'","'")'添加到company_name字段.这允许onclick事件触发,但确认消息显示为"Jane s Welding Company".
<a href="#" onclick="return Actionclick('<%= Url.Action("Activate", new {id = item.company_id}) %>', '<%= Html.Encode(item.company1.company_name.Replace("'", "'")) %>');" class="fg-button fg-button-icon-solo ui-state-default ui-corner-all"><span class="ui-icon ui-icon-refresh"></span></a>
<script type="text/javascript">
function Actionclick(url, companyName)
{
if (confirm('This action will activate this company\'s primary company ('+companyName+') and all of its other subsidiaries. Continue?'))
{
location.href = url;
};
};
Run Code Online (Sandbox Code Playgroud)
编辑 确认消息显示' 在消息而不是'.当我在这里打字时,它取代了' 用'.添加空格以便不会发生.我想知道将它传递给我的onclick事件的最佳方法,并且还可以在消息中正确显示它而不进行多次替换(如果有更好的方法).
apostrophe ×1
asp.net-mvc ×1
escaping ×1
html ×1
java ×1
javascript ×1
jquery ×1
jsp ×1
parameters ×1