I am trying to make a div where I include PHP web pages into it, however when I click any link inside the div, it loads in new window.
Does anyone know how to solve this problem?
I also tried using an iframe instead of a div but it caused other problems.
HTML code:
<div id="cover5">
<div id="warning">
<?php include 'SignIn.php'; ?>
<p align="center">
<a href="#" onclick="javascript:cover5();">Home</a>
</p>
</div>
</div>
JS code:
function cover5() {
var cover = document.getElementById('cover5');
if (vis) {
vis = 0;
cover.style.display='block';
}
else {
vis = 1;
cover.style.display='none';
}
}
You have to make a distinction bitween the client-side and the server-side of a Web application.
<?php include 'SignIn.php'; ?>is a server-side command, because of the<?php ?>, which means that the user will never see that line exactly.If your
SignIn.phpfile contains for example<a href="go-there.php">my link</a>, the user will only get the ouput of that inclusion, i.e.When the user clicks on the link, his browser will load it as if this
<a />would have been hard written within your HTML code directly, and then open it in a new window.I don’t no how to do it using native JS, but with jQuery, you can try something like this: