dqajyxqem115006813 2019-05-03 17:03
浏览 81

除非在index.php上,否则按钮或其他表单元素+ onclick元素将无法在页面上工作

I have some PNG images that should be clickable (ex.onclick="changeCamera()").

They work fine as long as I put them in the index.php page, but this element (or others like buttons and input fields) just won't work on my other pages where I need them to work.

I'm only using the index.php page as the "home" page, and all the rest of my pages open with <?php include(pagina($_GET['pagina'])); ?> in the <SECTION> part. I don't know PHP, it's something that I copied from a previous project.

This is my index page where the buttons work just fine:

<?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>

This is my test page where nothing seems to work, and nothing is even clickable:

<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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器