通过 Java 脚本显示文件


display a file through java script

有没有办法在点击事件中使用javacript在html中显示具有.php扩展的文件,就像任何应该在不同点击时显示的文件一样?

你可以通过jquery来做到这一点,这是相当简单的方法

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $("#div1").load("your file url");
    });
});
</script>
</head>
<body>
<div id="div1"></div>
<button>load file</button>
</body>
</html>