Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation window.location.href is not working under IE 7/8/9

    Hi ,
    I am using java script to provide a page to the client, in the page there are two checkboxes, i.e. "All countries" and "Asian Countries", so when i check the checkbox "Asian Countries" and click replot button, the page displays only asain counties but after some specific when the page reloads , it displays all other countries along with asian countries, and the checkbox "Asian Countries" is still selected, what i want is that after the page reloads it should display only the countries for which the checkbox was selected before. i am using window.location.href for providing the URL i.e.

    window.location.href = 'filename.html?gmlat=' + map.getCenter().lat() + '&gmlng=' + map.getCenter().lng() + '&gmzoom=' + map.getZoom() + '&allcountries=' + plotOptChbox[0].checked + '&asiancountries=' + plotOptChbox[1].checked;


    the above works fine under firefox and other browsers but not under IE 7/8/9 and we need it to work on IE. also i have already tried the below alternatives but issue not solved.

    location.href
    event.preventDefault()
    return false
    and document.write(window.location.href)

  • #2
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    Try
    Code:
    var mapLink = encodeURIComponent(map.getCenter().lat() + '&gmlng=' + map.getCenter().lng() + '&gmzoom=' + map.getZoom() + '&allcountries=' + plotOptChbox[0].checked + '&asiancountries=' + plotOptChbox[1].checked);
    
    window.location.href = 'filename.html?gmlat=' + mapLink;
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • #3
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi thanks for the reply,
    I have tried it, but when the page reloads after the refresh timer reaches zero, then the checkbox 0 (zero) is selected by default and shows all the countries, and the checkbox 1 is deselected . i want that when the page reloads it should reload with the same options selected as before.

  • #4
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    Does the page linked-to at filename.html?gmlat= use a script to dynamically select the checkboxes?

    If so, then visiting just filename.html (without the query-string) may not do this (unless there is some more script involved on that page). In which case, whether the boxes are checked, or unchecked, is entirely dependent on the browser and, for some, their settings. This behaviour is not defined: that is, it cannot be depended upon.

    In which case, a script would be needed that will store, and retrieve, the current checked-state(s) in (usually) a cookie.

    [I'm guessing that the boxes are only checked currently because this is how FF and the other browsers behave.]
    Last edited by AndrewGSW; 12-10-2012 at 08:52 PM.
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,901
    Thanks
    79
    Thanked 4,421 Times in 4,386 Posts
    Ummmm...the obvious queston, to me, is:

    What in the heck *IS* plotOptChbox???

    That is, how is that defined in your JS code?

    And what would REALLY help us see the problem would be to give us the URL of the site so we can try it ourselves.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #6
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,

    plotOptChbox is defined like this.
    var plotOptChbox = document.getElementsByName("plotOpt");

    actually it will not be possible to provide any access to the site or URL because it is running locally in the client network.

  • #7
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,901
    Thanks
    79
    Thanked 4,421 Times in 4,386 Posts
    Oh...nice. Only think I can think of is to make sure you really only have the "plotOpt" fields you expect to have.

    Okay...one more thing.

    Since you are, indeed, doing locaton.href that means you *SHOULD* be able to simply look at the browser's address bar and read exactly what it is the browser is seeing as the URL.

    So do that, both with MSIE and another browser, and compare them.

    If they look the same, then copy one (or both) here for us to look at.

    In other words, let's get JS our of the way as much as possible first, and only then go back to it, as needed.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #8
    Regular Coder
    Join Date
    May 2012
    Location
    France
    Posts
    224
    Thanks
    0
    Thanked 32 Times in 30 Posts
    You have probably to read the new URI (Try an alert (decodeURIComponent(window.location.search)) ) and to use (after a window onload) the corresponding data to reset your lists with javascript. The same string could be simultaneously stored in a cookie...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •