Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #13079 > unrolled thread
| Started by | Robert Baer <robertbaer@localnet.com> |
|---|---|
| First post | 2012-03-26 21:41 -0800 |
| Last post | 2012-04-07 07:51 +0000 |
| Articles | 10 — 6 participants |
Back to article view | Back to comp.lang.javascript
How call program and/or conditional display Robert Baer <robertbaer@localnet.com> - 2012-03-26 21:41 -0800
Re: How call program and/or conditional display Stefan Weiss <krewecherl@gmail.com> - 2012-03-27 18:32 +0200
Re: How call program and/or conditional display Robert Baer <robertbaer@localnet.com> - 2012-03-27 10:29 -0800
Re: How call program and/or conditional display Dr J R Stockton <reply1213@merlyn.demon.co.uk.not.invalid> - 2012-03-28 18:53 +0100
Re: How call program and/or conditional display Robert Baer <robertbaer@localnet.com> - 2012-03-30 00:56 -0800
Re: How call program and/or conditional display Scott Sauyet <scott.sauyet@gmail.com> - 2012-03-30 04:05 -0700
Re: How call program and/or conditional display Bart Van der Donck <bart@nijlen.com> - 2012-04-05 07:15 -0700
Re: How call program and/or conditional display "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-04-05 22:56 +0000
Re: How call program and/or conditional display Bart Van der Donck <bart@nijlen.com> - 2012-04-07 00:32 -0700
Re: How call program and/or conditional display "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-04-07 07:51 +0000
| From | Robert Baer <robertbaer@localnet.com> |
|---|---|
| Date | 2012-03-26 21:41 -0800 |
| Subject | How call program and/or conditional display |
| Message-ID | <P4ydnWrnbOuL2OzSnZ2dnUVZ_gqdnZ2d@posted.localnet> |
OK, in an HTML page via a JS function, i get a user's country code. How do i either pass that to the HTML code to conditionally run/show results from part of that code, or conditionally run/jump to another HTML page as if one clicked on an href?
[toc] | [next] | [standalone]
| From | Stefan Weiss <krewecherl@gmail.com> |
|---|---|
| Date | 2012-03-27 18:32 +0200 |
| Message-ID | <jksq3q$la5$1@news.albasani.net> |
| In reply to | #13079 |
On 2012-03-27 07:41, Robert Baer wrote:
> OK, in an HTML page via a JS function, i get a user's country code.
> How do i either pass that to the HTML code to conditionally run/show
> results from part of that code, or conditionally run/jump to another
> HTML page as if one clicked on an href?
First of all, the appropriate place to select and assemble region
dependent content is on the server side. In the following, I'm assuming
you're limited to JS for some reason.
To navigate to a new page you can use the "location" object:
window.location.href = "http://blah/page?cc=" + myCC;
This will trigger a new request, of course. It will also mess with the
visitors' history when they try to use the back button. That can be
worked around by using the replace() method:
window.location.replace("http://blah/page?cc=" + myCC);
Still, not recommended.
If you want show or hide areas of your page depending on the country
code, you could set their CSS display value:
document.getElementById("para-india").style.display = "block";
document.getElementById("para-europe").style.display = "none";
All of the regional variants have to be present on the page for this to
work. Visitors without JS will only ever see the initial state, which
will probably have only one of these blocks visible by default. Visitors
without CSS support (this includes search engines!) will see and
potentially index everything.
If you want to load the regional content after the original page has
loaded, use an XMLHttpRequest. An introduction to Ajax would go too far
here, but there are many tutorials and examples on the web and in the
archives of this group. The FAQ has some pointers as well. Use the
Google cached version if the FAQ is down again.
Again - the cleaner, faster and usually simpler way to do this is not in
the client, but on the server.
- stefan
[toc] | [prev] | [next] | [standalone]
| From | Robert Baer <robertbaer@localnet.com> |
|---|---|
| Date | 2012-03-27 10:29 -0800 |
| Message-ID | <BtmdnYafb4luZezSnZ2dnUVZ_qqdnZ2d@posted.localnet> |
| In reply to | #13090 |
Stefan Weiss wrote:
> On 2012-03-27 07:41, Robert Baer wrote:
>> OK, in an HTML page via a JS function, i get a user's country code.
>> How do i either pass that to the HTML code to conditionally run/show
>> results from part of that code, or conditionally run/jump to another
>> HTML page as if one clicked on an href?
>
> First of all, the appropriate place to select and assemble region
> dependent content is on the server side. In the following, I'm assuming
> you're limited to JS for some reason.
>
> To navigate to a new page you can use the "location" object:
>
> window.location.href = "http://blah/page?cc=" + myCC;
>
> This will trigger a new request, of course. It will also mess with the
> visitors' history when they try to use the back button. That can be
> worked around by using the replace() method:
>
> window.location.replace("http://blah/page?cc=" + myCC);
>
> Still, not recommended.
>
> If you want show or hide areas of your page depending on the country
> code, you could set their CSS display value:
>
> document.getElementById("para-india").style.display = "block";
> document.getElementById("para-europe").style.display = "none";
>
> All of the regional variants have to be present on the page for this to
> work. Visitors without JS will only ever see the initial state, which
> will probably have only one of these blocks visible by default. Visitors
> without CSS support (this includes search engines!) will see and
> potentially index everything.
>
> If you want to load the regional content after the original page has
> loaded, use an XMLHttpRequest. An introduction to Ajax would go too far
> here, but there are many tutorials and examples on the web and in the
> archives of this group. The FAQ has some pointers as well. Use the
> Google cached version if the FAQ is down again.
>
> Again - the cleaner, faster and usually simpler way to do this is not in
> the client, but on the server.
>
>
> - stefan
Thank you very much; i will play around with these ideas and see how
well dumb, stupid me does.
It is impossible for the server (as configured, and i have absolutely
NO say over that) to do anything WRT client data.
Google Analytics cannot and will not get any info beyond the fact
that the first/main page has been accessed (ie: just a dumb counter).
Things like:
<a href="http://www.oil4lessllc.com/6222350.PDF"
onClick="that=this;_gaq.push(['_trackEvent,'pdf','download','PatM',that.href]);setTimeout(function()
{ location.href=that.href }, 200);return false;">Mosley (Titan's HV
regulator)</a><br>
just plainly do not work no matter what is done with the code.
Once in a great while RANDOMLY maybe ONE of the lines like that works,
but it is very rare.
Hell, it is so bad that even the 301 permanent redirect does not
always work! Accessing one way at times gets recorded the other way -
but results for viewer / browser appears to be the full http:// but
stupid, dumb i cannot tell.
Thanks again.
[toc] | [prev] | [next] | [standalone]
| From | Dr J R Stockton <reply1213@merlyn.demon.co.uk.not.invalid> |
|---|---|
| Date | 2012-03-28 18:53 +0100 |
| Message-ID | <7GDBICFHA1cPFwx7@invalid.uk.co.demon.merlyn.invalid> |
| In reply to | #13079 |
In comp.lang.javascript message <P4ydnWrnbOuL2OzSnZ2dnUVZ_gqdnZ2d@posted .localnet>, Mon, 26 Mar 2012 21:41:50, Robert Baer <robertbaer@localnet.com> posted: > OK, in an HTML page via a JS function, i get a user's country code. > How do i either pass that to the HTML code to conditionally run/show >results from part of that code, or conditionally run/jump to another >HTML page as if one clicked on an href? A country code set in a computer does not necessarily indicate the current preferences of the current user. If alternatives are provided, the user should be enabled to change preferences at any time, without loss of entered data. -- (c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME. Web <http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms and links; Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc. No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
[toc] | [prev] | [next] | [standalone]
| From | Robert Baer <robertbaer@localnet.com> |
|---|---|
| Date | 2012-03-30 00:56 -0800 |
| Message-ID | <kbCdnczBBcjD-ujSnZ2dnUVZ_oudnZ2d@posted.localnet> |
| In reply to | #13107 |
Dr J R Stockton wrote: > In comp.lang.javascript message<P4ydnWrnbOuL2OzSnZ2dnUVZ_gqdnZ2d@posted > .localnet>, Mon, 26 Mar 2012 21:41:50, Robert Baer > <robertbaer@localnet.com> posted: > >> OK, in an HTML page via a JS function, i get a user's country code. >> How do i either pass that to the HTML code to conditionally run/show >> results from part of that code, or conditionally run/jump to another >> HTML page as if one clicked on an href? > > A country code set in a computer does not necessarily indicate the > current preferences of the current user. * I seriously doubt that the following (working) code gets the data from there,: <script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script> <br>Country Code: <script language="JavaScript">document.write(geoip_country_code());</script> > > If alternatives are provided, the user should be enabled to change > preferences at any time, without loss of entered data. > * User does not and cannot enter data.
[toc] | [prev] | [next] | [standalone]
| From | Scott Sauyet <scott.sauyet@gmail.com> |
|---|---|
| Date | 2012-03-30 04:05 -0700 |
| Message-ID | <cd1238fc-e1d8-47ee-8c7a-3c3b7fc1953f@12g2000vba.googlegroups.com> |
| In reply to | #13130 |
Robert Baer wrote: > Dr J R Stockton wrote: >> A country code set in a computer does not necessarily indicate the >> current preferences of the current user. > > * I seriously doubt that the following (working) code gets the data from > there,: > <script language="JavaScript" > src="http://j.maxmind.com/app/geoip.js"></script> The "language" attribute of SCRIPT tags is no longer recommended. But if you download that script, you can see that it has already processed the location information server-side based (presumably) on the IP address of the request. You are not looking this up with client-side Javascript, only receiving the results in a Javascript- friendly way. -- Scott
[toc] | [prev] | [next] | [standalone]
| From | Bart Van der Donck <bart@nijlen.com> |
|---|---|
| Date | 2012-04-05 07:15 -0700 |
| Message-ID | <502d45fb-b198-4c11-8092-c64170544fd3@do6g2000vbb.googlegroups.com> |
| In reply to | #13161 |
Scott Sauyet wrote: > Robert Baer wrote: >> Dr J R Stockton wrote: >>> A country code set in a computer does not necessarily indicate >>> the current preferences of the current user. > >> * I seriously doubt that the following (working) code gets the data >> from there,: >> <script language="JavaScript" >> src="http://j.maxmind.com/app/geoip.js"></script> > > The "language" attribute of SCRIPT tags is no longer recommended. > > But if you download that script, you can see that it has already > processed the location information server-side based (presumably) on > the IP address of the request. Not presumably, but very sure. Javascript has simply no way to return such information. Given the situation of the original poster (no access to server-side scripting), it looks like this solution might help. As long as maxmind.com continues to provide such services, which is not obvious in the long run. For a more robust strategy, both actions should be done server-side: (a) performing the geo look-up (b) taking decisions based upon (a) Hope this helps, -- Bart
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exjxw.hannivoort@interxnl.net> |
|---|---|
| Date | 2012-04-05 22:56 +0000 |
| Message-ID | <XnsA02D995F6A5eejj99@194.109.133.133> |
| In reply to | #13244 |
Bart Van der Donck wrote on 05 apr 2012 in comp.lang.javascript: > Scott Sauyet wrote: > >> Robert Baer wrote: >>> Dr J R Stockton wrote: >>>> A country code set in a computer does not necessarily indicate >>>> the current preferences of the current user. >> >>> * I seriously doubt that the following (working) code gets the data >>> from there,: >>> <script language="JavaScript" >>> src="http://j.maxmind.com/app/geoip.js"></script> >> >> The "language" attribute of SCRIPT tags is no longer recommended. >> >> But if you download that script, you can see that it has already >> processed the location information server-side based (presumably) on >> the IP address of the request. > > Not presumably, but very sure. Javascript has simply no way to return > such information. Why this use of "Javascript" when "clientside scripting" is ment, Bart? Javascript can very well do any serverside thing. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Bart Van der Donck <bart@nijlen.com> |
|---|---|
| Date | 2012-04-07 00:32 -0700 |
| Message-ID | <3f7d5ca2-d6c8-46c4-b129-1c6dfc818c80@i18g2000vbx.googlegroups.com> |
| In reply to | #13252 |
"Evertjan." wrote: > Why this use of "Javascript" when "clientside scripting" is ment, Bart? > Javascript can very well do any serverside thing. True, but almost nobody uses it. According to a survey by W3Techs, | JavaScript is used by less than 0.1% of all the websites | whose server-side programming language we know. http://w3techs.com/technologies/details/pl-js/all/all -- Bart
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exjxw.hannivoort@interxnl.net> |
|---|---|
| Date | 2012-04-07 07:51 +0000 |
| Message-ID | <XnsA02E6451D919Feejj99@194.109.133.133> |
| In reply to | #13285 |
Bart Van der Donck wrote on 07 apr 2012 in comp.lang.javascript: > "Evertjan." wrote: > >> Why this use of "Javascript" when "clientside scripting" is ment, Bart? >> Javascript can very well do any serverside thing. > > True, but almost nobody uses it. According to a survey by W3Techs, > > | JavaScript is used by less than 0.1% of all the websites > | whose server-side programming language we know. > > http://w3techs.com/technologies/details/pl-js/all/all Active "Javascript" clientside programming is probably used by less than 0.001% of the human population, and even less of the total animal population of this world. This does not mean one should use the word "javascript" as a generic for "clientside web programming" in this NG mostly frequented [like "hangjongeren"] by the subspecies "Javascript programmers". > whose server-side programming language we know. Kind of "life as we know [it]" statement. ;-) -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web