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 best solutions below
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
- window.location is not working javascript
- use parameters in window.location.replace
- How to find current page url (like "index.html")?
- Attach a parameter from Angular after a path in window.location
- Refresh an open window that was opened with window.open when the url hash changes
- Add two possible paths with "window.location.href " under the same condition
- if window.location == index (homepage)
- C# - Changing Window Address when making an AJAX Call
- setInterval breaks on window.locaion / window.open
- Dynamically sorting the table along with other few selection criteria via javascript and php
- windows.location.href throws error on IE10 using vbscript
- ie vs chrome window.location.href and <base> tag
- Series of Ajax request doesn't wait for finish
- Using JS in PHP Variable
- Tidying Javascript, Catching and manipulating URLs
Related Questions in EXCEPT
- LINQ Except/Distinct based on few columns only, to not add duplicates
- Python: Multiple try except blocks in one?
- MySQL except clause doesnt work
- How to use a column list in a database trigger on SAP HANA
- Selecting similar videos except for current one using MySQL
- Python - Determine if an exception was raised in a function
- What is the analogue of EXCEPT clause in SQL in Pandas?
- Invalid syntax for except ValueError
- Python empty list Exception
- except script error - extra characters after close-quote while executing
- if window.location == index (homepage)
- MDX - Calculated Member with EXCEPT will not roll-up at all?
- python try except in socket not working
- How do you use try except for library specific errors?
- Except Finally - Operator
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)
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?
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!! :)