I am trying to close child window if host name are same of parent and child but its
<script type="text/javascript">
$(document).ready(function () {
if (window.opener) {
if (window.opener.location.indexOf(document.location.hostname) != -1) {
window.opener.location = window.location;
window.close();
}
}
});
</script>
and getting this error
Error: window.opener.location.indexOf is not a function
Source File: https://example.com/default
Line: 100
The location
object is not a string, array, or any other object which has an indexOf
method. Perhaps you meant to use opener.location.href.indexOf(...)
?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With