Does anyone know how to implement the following JavaScript process? I`m using colorbox to display iframe.
following 2 codes are what I`ve tried:
1
<div>
<a href='#' onclick='parent.$.colorbox.close();linkto();'>
<img src="../images/test.png" alt=“#” >
</a>
<script>
function linkto() {
location.href = "https://www.test.com";
}
</script>
</div>
2
<div>
<a href='#' onclick='parent.$.colorbox.close(); window.location.href ='https://www.test.com;'>
<img src="../images/test.png" alt=“#” >
</a>
</div>
You can use window.top.location.href to target the top most window element and redirect to the specified page. This can be done from within an
iframe`.
HTML:
<a href='#' onclick='parent.$.colorbox.close(); linkTo();">
JS:
function linkTo() {
window.top.location.href = "https://www.test.com";
}