Javascript / onclick werkt niet op andere pagina's alleen op index pagina

Status
Niet open voor verdere reacties.

Molovhic

Gebruiker
Lid geworden
27 mei 2016
Berichten
76
Dag allemaal

Ik heb een projectje waar ik bepaalde png's van kleur laat veranderen zodra je er op klikt.
Ik maak in eerste instantie gebruik van GET pagina zodat ik maar 1 index.php pagina heb met opmaak.
De rest van de pagina's (in dit geval de testpagina) opent dus in de <section>.

De iconen heb ik zowel op de index pagina (onder de header) geplaatst, als op de testpagina.
Het bizare voor mij is dat deze op de index pagina wel werken..
Echter zodra ik een andere pagina open in het section gedeelte (dus met GET pagina) de Javascript
niet meer werkt op de png's..

Dit geldt ook voor eender welke button ik maak op een andere pagina dan de index..
Vind het raar want in andere projecten maak ik ook altijd gebruik van de GET pagina functie en
daar werkt het wel naar behoren.. dit terwijl alles hetzelfde is..

Ik test dit op de usbwebserver op dit moment..
Heb heel het project als zip bestand toegevoegd, hopelijk kan iemand er aan uit wat er aan de hand is..

Gr
 

Bijlagen

  • audittest1.zip
    132 KB · Weergaven: 26
Ik wil best kijken, maar dan zie ik graag de relevante code. Gezien ik geen zip-file kan openen. (mobiel) :)
 
Bij deze :)

index pagina:
HTML:
<?php
session_start();
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>

Test pagina:

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>
 
Bij deze is het dus opgelost, na lang zoeken vond ik de fout in het feit dat de section in de css in position:relative; stond..
eens dit weg was werkten alle functies...:thumb:
 
Status
Niet open voor verdere reacties.
Steun Ons

Nieuwste berichten

Terug
Bovenaan Onderaan