因此,我一直在到处寻找解决问题的方法,但是我认为我已经尝试了所有方法,但是我的代码根本无法正常工作。

我试图将txt文件的一些文本放入iframe中,并且实际上正在读取它,但是,当我尝试更改CSS时,标题中出现了以下消息:“未声明框架文档的字符编码。”

这是我的代码:

    <!DOCTYPE  html>
<html lang = "pt">
<head>
    <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
    <meta content="utf-8" http-equiv="encoding">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<style>
h1{
    position: absolute;
    left:85px;
    top:0px;
}
.LOGO{
    position: absolute;
    width:70px;
    height:70px;
    z-index: 2;
}
.portugal{
    position: absolute;
    top: 65px;
    left: 0px;
    width:auto;
    height:auto;
    z-index: 1;
}
.PT01{
    position: relative;
    top: 438px;
    left:560px;
    width:20px;
    height:20px;
    z-index: 3;
}

</style>
</head>
<body>
<script>
    var x = document.getElementsByTagName("PT01");
    if(x.id == 'PT01'){
        $("#div1").css("border-style","none");
        $("#div1").css("position",'relative');
        $("#div1").css("top",'315px');
        $("#div1").css("left",'535px');
        $("#div1").css("width",'auto');
        $("#div1").css("height",'auto');
        $("#div1").css("zIndex",'4');
    }

</script>

    <img class = "LOGO" src = "http://www.chronopost.pt/sites/all/themes/custom/quimera/favicon.ico"/> <h1> Informações Package Chronopost </h1>
    <img class = "portugal" src = "http://s2.thingpic.com/images/HV/9N2YRDXBuosfkppy9Jut8Tvx.png"/>
    <img class = "PT01"  name = "PT01" src = "http://www.chronopost.pt/sites/all/themes/custom/quimera/favicon.ico"/>
    <iframe id='div1' src = "PT01.txt">
    </iframe>

</body>
</html>


希望你能帮我这个忙!我只是一个学生,我想学习更多。
谢谢!

最佳答案

可能重复的here

您可以尝试将其添加到iframe标记之间:

<meta http-equiv="Content-type" content="text/html;charset=UTF-8">

10-02 19:49