JavaScript: window.location to String
Info by Stefan Trost | 2015-09-26 at 11:28
Even though it sometimes seems, window.location is not a string but an object. Therefore, we have to convert window.location into a string before we can use it with string functions such as .indexOf().
For converting window.location to a string, there are several possibilities:
- var s = window.location.toString();
- var s = window.location.href;
- var s = String(window.location);
After that, our string variable s contains our URL so that we can further work with it.
About the Author
You can find Software by Stefan Trost on sttmedia.com. Do you need an individual software solution according to your needs? - sttmedia.com/contact
Show Profile
Related Topics
PHP: Check Strings with Ctype-Functions for Character Classes
Article | 0 Comments
Convert many CSV Files to XLSX or ODS Spreadsheets
Tutorial | 0 Comments
How to Replace multiple Texts at the same Time
Tutorial | 0 Comments
JavaScript: window.location.indexOf not working
Question | 1 Answer
Android Programming: Receive Responce from HTTP POST Request
Tutorial | 0 Comments
How to resize Image before Upload in Browser
Tutorial | 13 Comments
Color Values: Convert RGB, CMYK, CMY, HSV, TColor and XYZ Values
Tutorial | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.