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 6468435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:53:22+00:00 2026-05-25T05:53:22+00:00

Trying to figure out a way to use Javascript to set up a little

  • 0

Trying to figure out a way to use Javascript to set up a little if-else statement using only part of the url to determine if it should go somewhere or not. So far what I got is,

<script>
       if (url==example.com) {
       window.open('1stoption','1stoption');
       } else {
               window.open('2ndoption','2ndoption');
              }

The problems so far are that it doesnt count if its exampample.com/whatever or anything like that.

Thanks for any help.

*edit Thanks guys it worked but I worded my question wrong, it should be more along the lines of showing a link but having the link go to two separate pages depending on the url. This stuff works and I’m kicking it around to get it to work my way too. Thanks alot.

  • 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-25T05:53:23+00:00Added an answer on May 25, 2026 at 5:53 am

    maybe this is what you want?

    <script type="text/javascript">
    if (url.indexOf("example.com") != -1) {
        window.open('1stoption','1stoption');
    } else {
        window.open('2ndoption','2ndoption');
    }
    </script>
    

    This will open window first option if it finds example.com anywhere within the url

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

Sidebar

Related Questions

Trying to figure out a way to use Javascript to set up a little
I'm trying to figure out a way to use tar+pipes on a Ubuntu Server
I am trying to figure out how to use the UIIMagePicker or some way
I've recently started learning/using django; I'm trying to figure out a way to have
I'm trying to figure out a way to add a self-update feature to a
I'm trying to figure out a way to detect files that are not opened
I'm trying to figure out a way to automatically cast something to an Action
I am trying to figure out a way to pre-process few things before my
I'm trying to figure out a way to find out which files were affected
I'm trying to figure out a way to serialize some Django model object to

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.