Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6241915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:51:15+00:00 2026-05-24T11:51:15+00:00

I have the following code: echo <script type=’text/javascript’> if(window.location.href.toLowerCase().indexOf(‘test’) != -1) { } else

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T11:51:16+00:00Added an answer on May 24, 2026 at 11:51 am

    You should understand this order.

    1. PHP executes script and generate HTML/JS/etc
    2. Then browser get it, parse and execute.

    So you should use any of php condition to avoid printing “test” in some cases

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have the following code : <input type=text value=<?php echo $_GET['msg']; ?>> This input
I have the following js files in my code for EditInPlace... <?php echo $javascript->link('jquery.js');?>
I have the following line of code - <a href=/wordpress/wp-content/trackclicks/clickcounter.php?var=<?php echo $var3; ?> onclick=return
I have the following PHP script : <?php header('Content-type: text/xml'); mysql_connect('localhost', 'root', 'root'); mysql_select_db('sportApp');
I have the following code in a PHP script: <?php if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1')))
I have the following code (taken from actual script): $result=mysql_query($sql); while($row=mysql_fetch_assoc($result)) { $auth_token=$row['oauth_token']; $auth_token_secret=$row['oauth_token_secret'];
I have the following code in header.php to echo the body's id: <body id=<?php
I have following javascript code. Its a timer code. Timer stops if quiz is
I have the following code in a script. The problem is That I want
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.