除非在index.php

时间:2019-05-03 17:04:00

标签: javascript php html onclick

我有一些应该可以点击的PNG图片(例如onclick="changeCamera()")。

只要我将它们放在index.php页面中,它们就可以正常工作,但是该元素(或其他按钮和输入字段)在我需要它们工作的其他页面上将无法使用。

我仅将index.php页面用作“主页”页面,其余所有页面都在<?php include(pagina($_GET['pagina'])); ?>部分中以<SECTION>打开。我不知道PHP,这是我从上一个项目复制来的。

这是我的索引页面,按钮可以正常工作:

<?php
include("inc/inc_pagina.php");
if(!isset($_GET['pagina'])){
    $_GET['pagina'] = "home";
}
?>



<!DOCTYPE html>
<html>
    <head>
        <title> test site </title>
        <meta charset="utf-8">
        <meta name="description" content="Test website">
        <link rel="stylesheet" type="text/css" href="css/style.css">
        <script type="text/javascript" src="javascript/buttons.js"></script>
    </head>
<body>
    <header>
        <h1> test1</h1>
    <nav>
        <ul id="main-menu">
            <li><a href="index.php?pagina=home" target="_self">Home</a></li>
            <li><a href="index.php?pagina=test">Testpagina</a></li>
            <!-- <li><a href="http://validator.w3.org/">w3c validator</a></li> -->
        </ul>
    </nav>
    </header>
    <br ><br ><br ><br ><br ><br >
    <img src="images/alert2.png" id="alert" onclick="changeAlert()" style="cursor:pointer;" width="25px" height="25px">
        <img src="images/na2.png" id="na" onclick="changeNa()" style="cursor:pointer;" width="25px" height="25px">
        <img src="images/checked2.png" id="checked" onclick="changeChecked()" style="cursor:pointer;" width="25px" height="25px">
        <img src="images/error2.png" id="error" onclick="changeError()" style="cursor:pointer;" width="25px" height="25px">
        <img src="images/comment2.png" id="comment" onclick="changeComment()" style="cursor:pointer;" width="22px" height="22px">
        <img src="images/camera2.png" id="camera" onclick="changeCamera()" style="cursor:pointer;" width="25px" height="25px">
    <section>
        <?php include(pagina($_GET['pagina'])); ?>
    </section>
    <footer>Copyright © 2019
    </footer>
</body>
</html>

这是我的测试页,其中似乎没有任何作用,甚至都无法点击:

<script type="text/javascript" src="javascript/buttons.js"></script>
<img src="images/alert2.png" id="alert" onclick="changeAlert()" style="cursor:pointer;" width="25px" height="25px"/></br>
<img src="images/na2.png" id="na" onclick="changeNa()" style="cursor:pointer;" width="25px" height="25px"></br>
<img src="images/checked2.png" id="checked" onclick="changeChecked()" style="cursor:pointer;" width="25px" height="25px"></br>
<img src="images/error2.png" id="error" onclick="changeError()" style="cursor:pointer;" width="25px" height="25px"></br>
<img src="images/comment2.png" id="comment" onclick="changeComment()" style="cursor:pointer;" width="22px" height="22px"></br>
<img src="images/camera2.png" id="camera" onclick="changeCamera()" style="cursor:pointer;" width="25px" height="25px"></br>

0 个答案:

没有答案