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
MySQL: Line Breaks in MySQL
Tip | 0 Comments
JavaScript: window.location.indexOf not working
Question | 1 Answer
Convert many CSV Files to XLSX or ODS Spreadsheets
Tutorial | 0 Comments
How to resize Image before Upload in Browser
Tutorial | 13 Comments
Android Programming: Receive Responce from HTTP POST Request
Tutorial | 0 Comments
JavaScript: Get current Date and Time
Tutorial | 1 Comment
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.