gpt4 book ai didi

javascript - 在警报中显示之前格式化字符串以添加\n?

转载 作者:行者123 更新时间:2023-11-30 20:59:14 25 4
gpt4 key购买 nike

我有以下来自后端的字符串,我需要先格式化该字符串,然后再将其显示在警报消息中。

我们如何使用 Apex 代码或使用 JavaScript 代码来做到这一点?我们如何为每个 .o 放置 \n

Try adding the above to your web page, then load the page and see if it works. If it doesn't, you probably have a bug. Specifically, please:  • Be sure you typed everything exactly as it appears,:    o Third Party Details   • Upload the following documents in the Requestor Required Documentation section:    o Proposal    o Relevant Documentation

我正在使用 Visualforce 页面和 Controller 。

    <!DOCTYPE html>
<html>
<body>

<h2>JavaScript Alert</h2>

<button onclick="myFunction()">Try it</button>

<script>
function myFunction() {
alert("Try adding the above to your web page, then load the page and see if it works.
If it doesn't, you probably have a bug.\n Specifically, please:\n  
• Be sure you typed everything exactly as it appears,:\n    
o Third Party Details   \n• Upload the following documents in the Requestor
Required Documentation section:      \no Proposal     \no Relevant Documentation");
}
</script>

</body>
</html>

我已经使用object.field.stripHtmlTags();格式化了代码

显示的警报应如下所示。但是如何为 .o 拆分字符串并使用顶点添加\n? enter image description here

最佳答案

试试这个

alert("Try adding the above to your web page, then load the page and see if it works. If it doesn 't, you probably have a bug.\n\n Specifically, please:\n\no Be sure you typed everything exactly as it appears,: \no Third Party Details\no Upload the following documents in the Requestor Required Documentation section: \no Proposal\ no Relevant Documentation ");

或者试试这个

alert("Try adding the above to your web page, then load the page and see if it works. If it doesn 't, you probably have a bug." + "\n\n Specifically, please:" + "\n\no Be sure you typed everything exactly as it appears" + "\no Third Party Details" + "\no Upload the following documents in the Requestor Required Documentation section" + "\no Proposal" + "\no Relevant Documentation ");

这是根据您更新的带有图片的帖子编辑的代码

alert("Try adding the above to your web page, then load the page and see if it works. If it doesn 't, you probably have a bug."+"\n\n Specifically, please:"+"\n\n• Be sure you typed everything exactly as it appears"+ "t\no Third Party Details"+"\n• Upload the following documents in the Requestor Required"+"\n Documentation section" +"\no Proposal"+"\no Relevant Documentation ");

关于javascript - 在警报中显示之前格式化字符串以添加\n?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47290958/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com