[英]Jsoup transform my javascript string into a single line
I am having trouble with the .append function in Jsoup. 我在Jsoup中使用.append函数遇到麻烦。 I am appending my simple Javascript file response string to a Jsoup Element.
我将简单的Javascript文件响应字符串附加到Jsoup元素。 But after appending my response transforms into a single line which is hurting me a lot.
但是在附加我的回答后,它变成了一行,这让我很痛苦。
My string is like this 我的绳子是这样的
(function () {
var count = 0;
var root = this;
var require = root.require;
//var require = cordova.require;
require.config({
config: {
text: { //this hacks the text api to allow cross domain loading of the templates. it is needed only for the packaged applications
useXhr: function (url, protocol, hostname, port) {
//console.log("text.useXhr request came from : " + url + ", " + protocol + " and " + hostname);
return true;
//return true if you want to allow this url, given that the
//text plugin thinks the request is coming from protocol, hostname, port.
}
},
'is': {
isBundled: true
}
},
waitSeconds: 45,
baseUrl: 'scripts/app',
deps: ["app"],
BUt after appending to a Element it will become 追加到一个元素后,它会变成
(function () { var count = 0; var root = this; var require = root.require; //var require = cordova.require; require.config({ config: { text: { //this hacks the text api to allow cross domain loading of the templates. it is needed only for the packaged applications useXhr: function (url, protocol, hostname, port) { //console.log("text.useXhr request came from : " +
My Code is for this 我的代码是为此
String temp=script.attr("src");
temp=temp.replace("/"+Heirarchy, DomainName+"/"+Heirarchy.toLowerCase());
script.attr("src", temp);
script.removeAttr("data-main");
script.removeAttr("async");
String innerHtml="</script>\n<script>\n"+old_configString;
script.append(innerHtml);
old_configString is my Javascript response String.... old_configString是我的Javascript响应字符串。...
您应该使用DataNode添加脚本或样式。
script.after(new DataNode("<script>" + old_configString + "</script>", "http://domain.tld/path"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.