Reputation: 11
I want to open a window by Onclick of any element/links of my site, but I want to open it behind the current window, or when the new window opens it should minimize itself. I have made a function but it actually did not work
<?php if(!empty($directlink)){ ?>
<script type="text/javascript">
$(document).ready(function() {
var ec = "<?php echo $directlink; ?>";
$("head").append('<link rel="preconnect dns-prefetch" href="' + ec + '">');
$("body").one("click", function() {
window.open(ec, "_blank", "");
});
});
</script>
<?php } ?>
Upvotes: 1
Views: 42
Reputation: 624
This will work.
<?php if(!empty($directlink)){ ?>
<script type="text/javascript">
$(document).ready(function() {
var ec = "<?php echo $directlink; ?>";
$("body").on("click", function() {
window.open(ec, "", "width=300,height=300");
});
});
</script>
<?php } ?>
Upvotes: 0