if (window.location.href.toLowerCase is not working in a Sharepoint site.
-
$(document).ready(function () { debugger; if (window.location.href.toLowerCase = "https: Pages/HomePage.aspx") { test.makeSharePointReady1(); } I am trying to redirect to another site (say www.google.com) from a SharePoint site.
-
$(document).ready(function () { debugger; if (window.location.href.toLowerCase = "https: Pages/HomePage.aspx") { test.makeSharePointReady1(); } I am trying to redirect to another site (say www.google.com) from a SharePoint site.
A very simple and quick fix will be to change the = operator, to == operator.
if (window.location.href.toLowerCase == "https: Pages/HomePage.aspx") {
"=" is used to assign the value, and "==" is used to test equality. Also, once converted to lowerCase, there is no sense in having "Page/HomePage" in caps, they will also be in lower format. Anyways, just see if that works otherwise, change them to lower case as well.
The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~
-
$(document).ready(function () { debugger; if (window.location.href.toLowerCase = "https: Pages/HomePage.aspx") { test.makeSharePointReady1(); } I am trying to redirect to another site (say www.google.com) from a SharePoint site.
toLowerCase is also a method so you need (). Also, lowercase your text that you are comparing to.
if (window.location.href.toLowerCase() == "https://pages/homepage.aspx") {
There are two kinds of people in the world: those who can extrapolate from incomplete data. There are only 10 types of people in the world, those who understand binary and those who don't.
-
toLowerCase is also a method so you need (). Also, lowercase your text that you are comparing to.
if (window.location.href.toLowerCase() == "https://pages/homepage.aspx") {
There are two kinds of people in the world: those who can extrapolate from incomplete data. There are only 10 types of people in the world, those who understand binary and those who don't.
Except that a lower-case string will never be equal to a string that contains upper-case characters. :) Also, the protocol is missing the "//", and the server name is missing. But apart from that... :laugh:
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
$(document).ready(function () { debugger; if (window.location.href.toLowerCase = "https: Pages/HomePage.aspx") { test.makeSharePointReady1(); } I am trying to redirect to another site (say www.google.com) from a SharePoint site.
The
location.href
will return the full URL, including the server name. The string you're trying to compare it to does not contain the server name, and is missing the "//" from the protocol. Even if you make that string lower-case, it's never going to match the full URL. Assuming you only want to match the path, use thepathname
property instead of thehref
property:if (window.location.pathname.toLowerCase() == "/pages/homepage.aspx") {
...
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Except that a lower-case string will never be equal to a string that contains upper-case characters. :) Also, the protocol is missing the "//", and the server name is missing. But apart from that... :laugh:
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Richard Deeming wrote:
Except that a lower-case string will never be equal to a string that contains upper-case characters.
Ya, I didn't get that far into it. I had read the previous answer and noticed they missed that point. I guess I should have kept on looking. :-O
There are two kinds of people in the world: those who can extrapolate from incomplete data. There are only 10 types of people in the world, those who understand binary and those who don't.
-
toLowerCase is also a method so you need (). Also, lowercase your text that you are comparing to.
if (window.location.href.toLowerCase() == "https://pages/homepage.aspx") {
There are two kinds of people in the world: those who can extrapolate from incomplete data. There are only 10 types of people in the world, those who understand binary and those who don't.
exactly:thumbsup: