I have the following code:
echo "<script type='text/javascript'>
if(window.location.href.toLowerCase().indexOf('test') != -1) {
}
else
window.open('http://google.com', '_parent', '');
</script>";
echo "test";
The code executes successfully BUT if it will open http://google.com using window.open it still shows echo "test" before successfully redirecting to google.com.
Can I somehow prevent executing code after the else statement in the javascript (window.open('http://google.com', '_parent', '');)?
Thanks
EDIT: Does that seem that I just ask to ask? I thought that something might exist that I could use in javascript to stop browser from printing echo “test” if I reached else statement in javascript code.
You should understand this order.
So you should use any of php condition to avoid printing “test” in some cases