使用document.write()时css不起作用

时间:2018-03-18 04:12:02

标签: javascript html css

您好我在我的html中使用了materialize css,除了document.write()代码之外,所有内容似乎都被正确设置了样式。我还需要做什么才能对document.write()代码进行样式设置。

这是我的HTML:

public void StartProgram()
{
    string firstaction;
    bool exit = true;
    while (exit)
    {
        firstaction = SnapsEngine.SelectFrom2Buttons("New Contact", "Find Contact");

        if (firstaction == "New Contact")
        {
            NewContact();

        }



    }

}
        void Storeinfo(string contact,string address,string number)
        {
          contact = contact.ToLower();
           SnapsEngine.SaveStringToLocalStorage(itemName: contact + ":address", itemValue: address);
           SnapsEngine.SaveStringToLocalStorage(itemName: number + ":number", itemValue: number);

        }

        void NewContact ()
        {
            string contact = SnapsEngine.ReadString("Enter the contact name");
            string address = SnapsEngine.ReadMultiLineString("Enter " + contact + " address");
            string number = SnapsEngine.ReadString("Enter " + contact + " number");
            Storeinfo(contact:contact,address: address,number: number);
        }

1 个答案:

答案 0 :(得分:0)

如果您在页面加载完成后致电document.write(),您将编写一个新页面(“重置”当前页面)。

尝试innerHTML,而不是“覆盖”path-file-wrapper div内的HTML:

function uploadFile(fileInput) {
  var files = fileInput.files;
  var fileName = files[0].name.replace(/\.[^/.]+$/, "");
  var divToWrite = document.getElementsByClassName('file-path-wrapper')[0];
  divToWrite.innerHTML = "Volume: " + volume(fileName + '.stl') + "<br>Surface Area: " +surfaceArea(fileName + '.stl');
}