Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #18179 > unrolled thread
| Started by | "Tony" <tony.johansson@inport.com> |
|---|---|
| First post | 2013-01-21 08:13 +0100 |
| Last post | 2013-01-22 17:42 +0000 |
| Articles | 9 — 6 participants |
Back to article view | Back to comp.lang.javascript
What is the best way to call another html file "Tony" <tony.johansson@inport.com> - 2013-01-21 08:13 +0100
Re: What is the best way to call another html file "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-01-21 09:52 +0100
Re: What is the best way to call another html file "Tony" <tony.johansson@inport.com> - 2013-01-21 10:02 +0100
Re: What is the best way to call another html file brooklynb7 <brooklynb7@gmail.com> - 2013-01-21 01:23 -0800
Re: What is the best way to call another html file "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-01-21 10:55 +0100
Re: What is the best way to call another html file "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-01-21 10:49 +0100
Re: What is the best way to call another html file Osmo Saarikumpu <osmo@weppipakki.com> - 2013-01-22 10:09 +0200
Re: What is the best way to call another html file Danny <dann90038@gmail.com> - 2013-01-22 12:45 -0800
Re: What is the best way to call another html file Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> - 2013-01-22 17:42 +0000
| From | "Tony" <tony.johansson@inport.com> |
|---|---|
| Date | 2013-01-21 08:13 +0100 |
| Subject | What is the best way to call another html file |
| Message-ID | <kdipqs$8a6$1@dont-email.me> |
Hello! I have a website with several html files and I don't use any server processing code where the html files are located. I use json do get data from another server. For example to get all the ships and fill a select control. Now to my question what is the best approach to get another html file. I now use window.location like this window.location = "SelectShip.html"; this works but I just wonder if this is the normal way to do this. //Tony
[toc] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2013-01-21 09:52 +0100 |
| Message-ID | <XnsA14F646294240eejj99@194.109.133.133> |
| In reply to | #18179 |
Tony wrote on 21 jan 2013 in comp.lang.javascript:
> I have a website with several html files and I don't use any server
> processing code where the html files are located.
> I use json do get data from another server. For example to get all the
> ships and fill a select control.
I don't see where you could use json or a <select> to do fetch a url-local
page, 'SelectShip.html', as written below.
> Now to my question what is the best approach to get another html file.
> I now use window.location like this
> window.location = "SelectShip.html";
> this works but I just wonder if this is the normal way to do this.
"best" and "normal" are useless adjectives in programming,
as one should make his or her own conclusions out of own experience and
arguments read in this NG and elsewhere.
Are you happy with your code?
Is there anything to gain for the user by striving for "the best"?
Is "normality" a good thing?
My persomally preferred way would be not to use Javascript where html does
nicely:
<a href='SelectShip.html'>Select ship</a>
The standard [damn, now I do it myself] Javascript would be:
window.location.href = 'SelectShip.html';
but be warned that, if the execution engine is slow,
the next statement could be executed:
window.location.href = 'SelectShip.html';
alert('Do you read this alert?');
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | "Tony" <tony.johansson@inport.com> |
|---|---|
| Date | 2013-01-21 10:02 +0100 |
| Message-ID | <kdj06n$6bq$1@dont-email.me> |
| In reply to | #18181 |
"Evertjan." wrote in message news:XnsA14F646294240eejj99@194.109.133.133...
Tony wrote on 21 jan 2013 in comp.lang.javascript:
> I have a website with several html files and I don't use any server
> processing code where the html files are located.
> I use json do get data from another server. For example to get all the
> ships and fill a select control.
I don't see where you could use json or a <select> to do fetch a url-local
page, 'SelectShip.html', as written below.
> Now to my question what is the best approach to get another html file.
> I now use window.location like this
> window.location = "SelectShip.html";
> this works but I just wonder if this is the normal way to do this.
"best" and "normal" are useless adjectives in programming,
as one should make his or her own conclusions out of own experience and
arguments read in this NG and elsewhere.
Are you happy with your code?
Is there anything to gain for the user by striving for "the best"?
Is "normality" a good thing?
My persomally preferred way would be not to use Javascript where html does
nicely:
<a href='SelectShip.html'>Select ship</a>
The standard [damn, now I do it myself] Javascript would be:
window.location.href = 'SelectShip.html';
but be warned that, if the execution engine is slow,
the next statement could be executed:
window.location.href = 'SelectShip.html';
alert('Do you read this alert?');
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
I mean if I want to fetch a new html file automatically without having the
user to click on a control then is not any wrong to use
window.location = 'SelectShip.html';
instead of
window.location.href = 'SelectShip.html';
What is the difference between these two ways ?
//Tony
[toc] | [prev] | [next] | [standalone]
| From | brooklynb7 <brooklynb7@gmail.com> |
|---|---|
| Date | 2013-01-21 01:23 -0800 |
| Message-ID | <863efc58-06f2-4520-9509-881652ed7402@googlegroups.com> |
| In reply to | #18182 |
I think you can use console.log(window.location) and console.log(window.location.href), then you will know the difference.
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2013-01-21 10:55 +0100 |
| Message-ID | <XnsA14F6F2979F49eejj99@194.109.133.133> |
| In reply to | #18183 |
brooklynb7 wrote on 21 jan 2013 in comp.lang.javascript: > I think you can use console.log(window.location) and > console.log(window.location.href), then you will know the difference. Perhaps, but if you do not quote relevant parts of what you are responding on, many of us won't understand why you are posting this. Remember Usnet is not a synchronlous service, postings can arrive out of order or not at all on a specific news-server and are removed, depending on the settings of such server on time or memory-capacity, in an for the user unpredictable way. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2013-01-21 10:49 +0100 |
| Message-ID | <XnsA14F6E309EF60eejj99@194.109.133.133> |
| In reply to | #18182 |
Tony wrote on 21 jan 2013 in comp.lang.javascript:
[please do not quote signatures on usenet.
a decent newsreader obscures anything beow that, so I had to search for
your response]
> I mean if I want to fetch a new html file automatically without having
> the user to click on a control then is not any wrong to use
"Wrong"? Petrus [if you are into believing his methods] won't hold you
responsible for your surmized programming style missdeeds,
like he does not care about the other qualities mentioned above,
"Did it work as expected cross-browser-wise?" is all he will ask,
perhaps also, if he is an ancient programmer: "Did you sinfully spill
internet-bandwidth, cpu-time or hard-drive-memory?".
> window.location = 'SelectShip.html';
> instead of
> window.location.href = 'SelectShip.html';
>
> What is the difference between these two ways ?
.href being the default of window.location, should IMHO only be left out
if you understand that you really are calling this .href method.
So while it executes the same, defaults can obscure your understanding.
You can even leave out the window. part, as it is also default:
location.href = 'SelectShip.html';
or even:
location = 'SelectShip.html';
try also:
window.location.assign('SelectShip.html');
or if you want the same page:
window.location.reload();
================
Properties of window.location are:
window.location.href [default, this is a read/write property]
window.location.hostname [returns the domain name of the web host]
window.location.path [returns the path and filename of the current page]
window.location.port [returns the port of the web host (80 or 443)]
window.location.protocol [returns the web protocol used (http:// or
https://)]
Methods of window.location are:
window.location.replace('http://cnn.com') [loads & replaces history entry]
window.location.assign('http://cnn.com') [loads with new history entry]
window.location.reload() [reloads the page at hand]
Did I miss some?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Osmo Saarikumpu <osmo@weppipakki.com> |
|---|---|
| Date | 2013-01-22 10:09 +0200 |
| Message-ID | <kdlhfj$14b$1@speranza.aioe.org> |
| In reply to | #18184 |
On 21.1.2013 11:49, Evertjan. wrote:
> Properties of window.location are:
>
> window.location.href [default, this is a read/write property]
> window.location.hostname [returns the domain name of the web host]
> window.location.path [returns the path and filename of the current
> page] window.location.port [returns the port of the web host (80 or
> 443)] window.location.protocol [returns the web protocol used
> (http:// or https://)]
>
> Methods of window.location are:
>
> window.location.replace('http://cnn.com') [loads & replaces history
> entry] window.location.assign('http://cnn.com') [loads with new
> history entry] window.location.reload() [reloads the page at hand]
>
> Did I miss some?
The following seem to be popular:
window.location.host [returns the host name and port number]
window.location.hash [returns the part of the URL that follows the #
symbol, including the # symbol]
window.location.search [returns the part of the URL that follows the ?
symbol, including the ? symbol]
--
Best wishes, Osmo
[toc] | [prev] | [next] | [standalone]
| From | Danny <dann90038@gmail.com> |
|---|---|
| Date | 2013-01-22 12:45 -0800 |
| Message-ID | <204a63df-edd4-46b7-9fe6-2e8667b8647e@googlegroups.com> |
| In reply to | #18179 |
to Tony The "normal" way to fetch .html files is using HTML, <a href="YOURFILE.html"> :) </a>. So, is there anything wrong with using a hyperlink?
[toc] | [prev] | [next] | [standalone]
| From | Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> |
|---|---|
| Date | 2013-01-22 17:42 +0000 |
| Message-ID | <Mv1VQbKb+s$QFwAB@invalid.uk.co.demon.merlyn.invalid> |
| In reply to | #18179 |
In comp.lang.javascript message <kdipqs$8a6$1@dont-email.me>, Mon, 21 Jan 2013 08:13:31, Tony <tony.johansson@inport.com> posted: >I have a website with several html files and I don't use any server >processing code where the html files are located. >I use json do get data from another server. For example to get all the >ships and fill a select control. > >Now to my question what is the best approach to get another html file. >I now use window.location like this >window.location = "SelectShip.html"; >this works but I just wonder if this is the normal way to do this. Be aware that you can load new pages into an iframe; and, if they are from the same domain, you can then read the contents from JavaScript. -- (c) John Stockton, nr London UK Reply address via Home Page. news:comp.lang.javascript FAQ <http://www.jibbering.com/faq/index.html>. <http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources. <http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web