I wanna do a jquery action on every site except the homepage (index).
I can not find out how to setup the if-statement with window.location
thanks for your help
if window.location == index (homepage)
988 views Asked by Corrado At
2
There are 2 answers
2
Tobey
On
This should do what you are looking for as the pathname will be a single / if you are at the home page in MVC. I am not sure about webforms but would assume the same if not it would be the page name such as /Default.aspx.
(function selfRunning() {
if (window.location.pathname.length > 1) {
alert(window.location.pathname);
}
})();
Related Questions in IF-STATEMENT
- Basic Python Question: Shortening If Statements
- Why if condition work but else if condition doesn't work?
- How to list several items in the dialog box for execution?
- "if contains" with forbidden special characters
- bash if equals some file
- change binary data like "111 into 001" in python by using if else or using regex
- How much of a bonus do I get if I sell a specific number
- Conditional Concatenation for Exchange Contact Imports
- How can i correct a multiple choice question with multiple correct answers?
- IF AND OR Nested ArrayFormula not working - What am I missing?
- I can search one sheet, but can't manage to string two searches with the IFS function
- How to add 1 (or more generally, perform a simple operation) on a column based on a condition
- Playwright checking the text of a locator and replacing values
- Read a variable and printing it on a monitor - Arduino
- Comparison between two strings is not working
Related Questions in INDEXING
- How to give index id to my uploaded json file in FastAPI?
- operator class "gin_trgm_ops" does not exist for access method "gin"
- what is it? my question is what's the meaning of img[img]
- If composite indexing created - indexing is called?
- Autocomplete not working for apache spark in java vscode
- Pyside6, tableView.selectedIndexes, list index out of range
- Indexing in ServiceNow Jelly Report not working
- Wordpress | Page indexing Page is not indexed: Redirect error
- Why does my attempt to print the index of my array ALWAYS return 0.00?
- jQuery - Click and enable Button without affecting other foreach Laravel arrays
- std:array indexing and operator[]
- ChartJS indexing for datapoints
- How to make Postgres GIN index work with jsonb_* functions?
- Using Closing Stock Balance as Opening Stock in subsequent line item
- Using MYSQL optimise table with innodb_optimize_fulltext_only and innodb_ft_num_word_optimize options, how do I know when it's finished?
Related Questions in WINDOW.LOCATION
- useLocation location members are empty within HashRouter
- window.location.href Loads WHOLE URL When INCOMPLETE URL Input is Submitted by Form
- NextJS Exports error, location not defined
- Why won't Playwright work when triggering window.location.href in the Firefox project?
- how to show search result in another page using javascript
- Add form input to URL in a new tab
- window.location.assign() not working in axios "then" in mobile browsers in production
- Looping in window.location
- Inconsistent behavior of the URL constructor between Safari and Chrome, when working with custom URL schema
- Does the state will lose when refresh page in react-router v6?
- How to redirect after click on download link if onclick already used?
- window.location.href adding link to an existing hostname instead of replacing it
- JAVASCRIPT: After sending Item to Database (POST) the window.location.reload() does not work. How to refresh the Data in HTML-Template?
- how to check whether window.location.pathname ends with /search?
- react location.replace error when triggered by keydown
Related Questions in EXCEPT
- Find the employees who have NO dependents using EXCEPT (MINUS)
- Can't create an exception "ApiError"
- I cannot exit with EOFerror, and hence the program continues endlessly
- repeat Try and except with different option
- Databricks Python run all cells in another notebook except the last
- while loop exit after receive error in a try except
- How to use Except on two different types?
- Sql Anywhere : Find difference between two tables with same columns
- Use ExceptBy set operation with list of Keyselectors instead of single selector in C#
- How to Filter a Disconnected Table
- Listing all open workbooks except Current within combobox vba
- Powershell move folders with exclude
- Query with EXCEPT before GROUP BY fails
- How to integrate except: raise with sqlalchemy's exceptions? SQLAlchemyError not working
- Why are my try and except clauses not working?
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
You can do:
if(window.location.pathname != "{ do something }") { //run home page jquery. }But if prefer PHP like
<?php if ( !is_home() ) { ?> ==== jquery code here ===== <?php } ?>Good luck!! :)