Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-10-2012, 06:25 PM   PM User | #1
vdevil
New to the CF scene

 
Join Date: Dec 2012
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
vdevil is an unknown quantity at this point
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)
vdevil is offline   Reply With Quote
Old 12-10-2012, 06:43 PM   PM User | #2
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
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
AndrewGSW is offline   Reply With Quote
Old 12-10-2012, 08:23 PM   PM User | #3
vdevil
New to the CF scene

 
Join Date: Dec 2012
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
vdevil is an unknown quantity at this point
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.
vdevil is offline   Reply With Quote
Old 12-10-2012, 08:46 PM   PM User | #4
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
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.]
__________________
"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

Last edited by AndrewGSW; 12-10-2012 at 08:52 PM..
AndrewGSW is offline   Reply With Quote
Old 12-10-2012, 09:00 PM   PM User | #5
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,200
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Old Pedant is offline   Reply With Quote
Old 12-11-2012, 06:29 AM   PM User | #6
vdevil
New to the CF scene

 
Join Date: Dec 2012
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
vdevil is an unknown quantity at this point
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.
vdevil is offline   Reply With Quote
Old 12-11-2012, 07:25 AM   PM User | #7
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,200
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Old Pedant is offline   Reply With Quote
Old 12-11-2012, 01:07 PM   PM User | #8
007julien
Regular Coder

 
Join Date: May 2012
Location: France
Posts: 115
Thanks: 0
Thanked 17 Times in 15 Posts
007julien is an unknown quantity at this point
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...
007julien is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:10 AM.


Advertisement
Log in to turn off these ads.