我正在尝试从下面的脚本中获取以下值 使用此字段存储机会相关的帐户
<script>sfdcPage.setHelp('Opportunity.Account', 'Use this field to store the Account to which the Opportunity is related');</script>
我可以使用
访问这个脚本标签document.getElementsByTagName('tbody')[6].getElementsByTagName('script')[1];
你能告诉我吗? 非常感谢。
最佳答案
我不建议将 script
标签放在您的表格等中。换句话说,我不会将 script
标签与其他与内容相关的 HTML 混合在一起。如果你想为了 JS 的目的在你的 HTML 中存储一些信息,我会使用 data attributes相反。
虽然您的问题的简单答案是仅使用 innerHTML
或 innerText
属性,如下所示:
document.getElementsByTagName('tbody')[6].getElementsByTagName('script')[1].innerHTML;
关于Javascript : how to get value from a Script Tag,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17834293/