JavaScript Javascript: How to find a given string in a URL?

I have 2 long URLs that point to the same page, http://preview.tbwabox.co.nz/_v005/index.html#buying-a-car http://preview.tbwabox.co.nz/_v005/index.html#buying-a-house

and I would like to check if the URL has the string "buying-a-car" or "buying-a-house".

depending on the URL, it will show different default image in a carousel.

I tried,

if(window.location.href.indexOf("buying-a-car") > -1) {
 alert("your url contains the name buying a car");
}

But it is not working

Answer:1

I have a webapp that makes calls to a database. Every once in a while, we get a javascript alert dialog that says that the transaction was deadlocked. Honestly, we don't care if that happens because ...

I have a webapp that makes calls to a database. Every once in a while, we get a javascript alert dialog that says that the transaction was deadlocked. Honestly, we don't care if that happens because ...

  1. javascript alert block execution
  2. javascript alert block
  3. javascript block alert box

I'm trying to use formdata object to send form data to my server. I need this because one of my input fields is a file. However the formdata object is blank when I try to send the data to my server, ...

I'm trying to use formdata object to send form data to my server. I need this because one of my input fields is a file. However the formdata object is blank when I try to send the data to my server, ...

  1. formdata object empty
  2. form data empty object
  3. javascript formdata object empty
  4. formdata append empty object
  5. formdata returns empty object

I have a form, which allows to select an item from a dropdown list and upload a file. The name and the ID of the item are saved in a Spreadsheet document. Works with one file...but I want to upload ...

I have a form, which allows to select an item from a dropdown list and upload a file. The name and the ID of the item are saved in a Spreadsheet document. Works with one file...but I want to upload ...

  1. handling multiple files in python
  2. handling multiple files in vi
  3. handling multiple files in c
  4. handling multiple files in vi editor
  5. handling multiple files using awk
  6. vim handling multiple files
  7. handling multiple feature files in cucumber
  8. sftp handling multiple files simultaneously

I am following a tutorial [here][1] to make a Facebook like friend tagging system. But the tutorial lacks the "arrow navigating" capability like Facebook. I would like to figure out how to achieve ...

I am following a tutorial [here][1] to make a Facebook like friend tagging system. But the tutorial lacks the "arrow navigating" capability like Facebook. I would like to figure out how to achieve ...

  1. enable arrow navigation in excel
  2. how to enable arrow navigation