Javascript with window.location.href no longer working in Content Editor in Sharepoint 2010 where users have IE8 RRS feed

  • Question

  • I have recently found that when using a Sharepoint 2010 Content Editor web part to house some Javascript that the window.location.href (or window.location) is not working when the end users have IE8 installed on their PC's.  We have confirmed that the window.location.href is working if the users are on IE7 or Google Chrome with the same Javascript.  In addition, we added alert() to the javascript to ensure that it was infact running, which the alerts appeared on the screen with no issues.  The result that I am receiving in IE8 is that when the window.location.href is set to the url that the user should be directed to, it simply refreshes the current page and leaves the user where they originally were.

    I have seen the posts to have my site setup as a Trusted Site, but this is not an option for our company as they defined all internal Sharepoint sites as trusted already.  Besides this, having all users go into their Internet Options is not really a solution but a means to annoy your users.

    What I am looking for is a permanent solution that I can make within my javascript that will work for both IE7 and IE8 users within a Sharepoint 2010 environment.  If anyone has any suggestions, please let me know.  Thanks in advance.

    Below is a snipet from my javascript code for review:

    <script type="text/javascript">
    function RedirectUrl() {
    alert('button pressed');
    var tb = document.getElementById("tbSearch").value;
    var cs = document.getElementById("sfield").value;
    var url = "";
    if (tb != "") {
      url = "FilterName=" + cs + "&FilterMultiValue=*" + tb + "*";
      if (cs == "Request%5Fx0020%5FID1"){
       alert("Request%20ID%20Search.aspx?" + url)
       window.location.href = "Request%20ID%20Search.aspx?" + url;
      	else {  
        window.location.href = "All%20Requests.aspx?" + url;
       else {
        return false;
    function ClearUrl() {
    window.location.href = "All%20Requests.aspx";
    <span style="font-family: calibri; color: #000066; font-size: 14pt; font-weight: bold">Search</span>
    <span style="font-family: calibri; color: black">Search Field: </span>
    <select id="sfield" style="font-family: calibri; font-size: 10pt">
    <option value="Request%5Fx0020%5FID1">Request ID</option>
    </select> &#160; 
    <span style="font-family: calibri; color: black">Search Text: </span>
    <input id="tbSearch" onkeypress="if (event.keyCode == 13) document.getElementById(&#39;btnSearch&#39;).click()" style="font-family: calibri"/>
    <button id="btnSearch" onclick="return RedirectUrl();" type="submit" style="font-family: calibri">Search</button>
    <button id="btnClear" onclick="return ClearUrl();" type="submit" style="font-family: calibri">Clear Search</button> 
    <span style="font-family: calibri; color: #000066; font-size: 14pt; font-weight: bold">Search Results - All Requests</span> 

    • Moved by JasonGuo Thursday, May 22, 2014 7:26 AM
    Wednesday, May 21, 2014 3:22 PM


All replies

  • Just to give a little more information ... I did find that the window.open method does work in IE8 and Sharepoint 2010, but it isn't as nice as a simple redirect of the current window to the appropriate site.  So, still looking for another solution ...
    Wednesday, May 21, 2014 3:42 PM
  • Hi,

    According to your post, my understanding is that the window.location.href not worked in IE 8.

    I think the issue is likely due to the value of your variables. If they contain special or invalid characters, those needs to be passed through encodeURIComponent before being assigned to window.location.href.



    You can also use the following methods to check whether it works.





    Thanks & Regards,


    Jason Guo
    TechNet Community Support

    • Marked as answer by Lindali Friday, May 30, 2014 9:48 AM
    Thursday, May 22, 2014 10:09 AM