在Chrome中,这很好用,但在Android平板电脑和IE中的默认浏览器中查看页面时遇到问题。似乎问题在于设置innerHTML。
这是代码
function common_get_order_xml()
{
//console.log(common_get_common_order_xml());
var parser = new DOMParser(); //create a new DOMParser
var doc = parser.parseFromString(common_get_common_order_xml(), "application/xml"); //convert the string to xml
doc.getElementsByTagName('Mats')[0].innerHTML = mattes_get_mattes_xml().replace("<Mats>", "").replace("</Mats>", "").replace(/<fillet><\/fillet>/g, "").replace(/<fillet\/>/g, ""); //add the mattes, remove empty fillet tags
doc.getElementsByTagName('Openings')[0].innerHTML = mattes_get_openings_xml().replace("<Openings>", "").replace("</Openings>", ""); //Add the openings
if (typeof(moulding_get_moulding_xml()) != "undefined")
{
doc.getElementsByTagName('Moulding')[0].innerHTML = moulding_get_moulding_xml().replace("<Moulding>", "").replace("</Moulding>", ""); //Add the moulding
}
if (typeof(glazing_get_glass_xml()) != "undefined")
{
doc.getElementsByTagName('Glass')[0].innerHTML = glazing_get_glass_xml().replace("<Glass>", "").replace("</Glass>", ""); //Add the moulding
}
var serializer = new XMLSerializer(); //create a new XMLSerializer
common_order_xml = serializer.serializeToString(doc); //convert the xml back to a string
console.log(doc);
alert(common_order_xml);
common_set_sizes(doc);
common_set_total(common_order_xml);
return doc;
}
答案 0 :(得分:0)
function common_get_order_xml()
{
var mattes_xml = mattes_get_mattes_xml().multiReplace({"<fillet></fillet>" : "", "<fillet/>" : ""}); //remove empty fillet tags
common_order_xml = common_order_xml.replace("<Mats></Mats>", mattes_xml);
common_order_xml = common_order_xml.replace("<Openings></Openings>", mattes_get_openings_xml()); //Add the openings
var moulding_xml = moulding_get_moulding_xml();
if (typeof(moulding_xml) != "undefined")
{
common_order_xml = common_order_xml.replace("<Moulding></Moulding>", moulding_xml); //Add the openings
}
var glass_xml = glazing_get_glass_xml();
if (typeof(glass_xml) != "undefined")
{
common_order_xml = common_order_xml.replace("<Glass></Glass>", glass_xml); //Add the openings
}
var parser = new DOMParser(); //create a new DOMParser
var doc = parser.parseFromString(common_order_xml, "application/xml"); //convert the string to xml
common_set_sizes(doc);
common_set_total(common_order_xml);
return doc;
}