Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. if (window.location.href.toLowerCase is not working in a Sharepoint site.

if (window.location.href.toLowerCase is not working in a Sharepoint site.

Scheduled Pinned Locked Moved JavaScript
sharepointcomdebugging
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RameshLuked
    wrote on last edited by
    #1

    $(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 Z Richard DeemingR 3 Replies Last reply
    0
    • R RameshLuked

      $(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 Offline
      A Offline
      Afzaal Ahmad Zeeshan
      wrote on last edited by
      #2

      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 !~

      1 Reply Last reply
      0
      • R RameshLuked

        $(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.

        Z Offline
        Z Offline
        ZurdoDev
        wrote on last edited by
        #3

        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.

        Richard DeemingR K 2 Replies Last reply
        0
        • Z ZurdoDev

          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.

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #4

          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

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          Z 1 Reply Last reply
          0
          • R RameshLuked

            $(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.

            Richard DeemingR Offline
            Richard DeemingR Offline
            Richard Deeming
            wrote on last edited by
            #5

            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 the pathname property instead of the href 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

            "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

            1 Reply Last reply
            0
            • Richard DeemingR Richard Deeming

              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

              Z Offline
              Z Offline
              ZurdoDev
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              • Z ZurdoDev

                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.

                K Offline
                K Offline
                Karthik_Mahalingam
                wrote on last edited by
                #7

                exactly:thumbsup:

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups