JavaScript for local pages

I

I.N. Galidakis

I have many readers who save locally my web-pages for ease of reading.

When a page is loaded off my server, on my stats I get:
http://ioannis.virtualcomposer2000.com/xxx/yyy.html, etc.

When the page is loaded locally, on my stats I get:

file:///C:/Documents%20and%20Settings/CJU/%uBC14%uD0D5%20%uD654%uBA74/xxx.htm,
etc

or some other such nonsense, describing the path where the user saved the page.

Now, being a wholesomely evil person ;o), I intend to make it difficult for my
readers to save locally, hence I want to discuss the possibility of a little
JavaScript to keep readers from doing that.

My Stats code is a simple JavaScript. Among the various output values of this
code is the path name as above, hence it should be easy to write a simple
JavaScript that returns only the path name.

I know that JavaScripts which crash browsers exist, for example, by going
through a loop which opens a virtual infinity of windows. To conclude, and in
pseudocode:

Return (pathname)
if pathname from server, then do nothing
else keep opening windows till Jesus appears again on Earth.

It looks really simple to me, so should be doable, but I am not a JavaScript
programmer. Of course the reader can always cut the JS code out and read it
still, but most readers are not code gurus.

If anyone knows how to do this, I'd appreciate it and in return, I'll put on a
good word for you when you burn in hell for helping me out ;o)

Cheerio,
 
H

Harlan Messinger

I.N. Galidakis said:
I have many readers who save locally my web-pages for ease of reading.

When a page is loaded off my server, on my stats I get:
http://ioannis.virtualcomposer2000.com/xxx/yyy.html, etc.

When the page is loaded locally, on my stats I get:

file:///C:/Documents%20and%20Settings/CJU/%uBC14%uD0D5%20%uD654%uBA74/xxx.htm,
etc

or some other such nonsense, describing the path where the user saved the page.

Now, being a wholesomely evil person ;o), I intend to make it difficult for my
readers to save locally, hence I want to discuss the possibility of a little
JavaScript to keep readers from doing that.

My Stats code is a simple JavaScript. Among the various output values of this
code is the path name as above, hence it should be easy to write a simple
JavaScript that returns only the path name.

I know that JavaScripts which crash browsers exist, for example, by going
through a loop which opens a virtual infinity of windows. To conclude, and in
pseudocode:

Return (pathname)
if pathname from server, then do nothing
else keep opening windows till Jesus appears again on Earth.

It looks really simple to me, so should be doable, but I am not a JavaScript
programmer. Of course the reader can always cut the JS code out and read it
still, but most readers are not code gurus.

If anyone knows how to do this, I'd appreciate it and in return, I'll put on a
good word for you when you burn in hell for helping me out ;o)

It seems to me that a large share of the users who save your pages will
react to such a crash in the following manner: "Wow, this site's pages
have f'ed up my browser. Must be a virus or something. I'd better run a
virus scan right now and never go back to that site again." Best of luck
to you.
 
J

J.O. Aho

I.N. Galidakis said:
Now, being a wholesomely evil person ;o), I intend to make it difficult for my
readers to save locally, hence I want to discuss the possibility of a little
JavaScript to keep readers from doing that.

Do you be sure that the readers has enbled the javascript or jscript in their
browser?
What about users who uses things like privoxy, which can mangle harmful scripts?
What about tools that downloads web pages which modifies paths so they are
adjusted to the new location of the file?
Browsers with popup blockers?

There are quite many things you haven't really considered and in the long run
it will just kill your site.

If you have readers who want to save a copy of your articles, be happy and see
to that they will enjoy to come back to your site.
 
H

Harlan Messinger

Brian said:
<snip>

If you really don't want them to look at your pages off-line, then why
not add javascript to redirect them to the real page (or your homepage)
if the url isn't what you expect?

Something like (not tested):

<script type="text/javascript" >
if ((document.location.hostname != "localhost") &&
(document.location.hostname != "ioannis.virtualcomposer2000.com"))
{
if (document.images)
top.location.replace("http://ioannis.virtualcomposer2000.com");
else
top.location.href = "http://ioannis.virtualcomposer2000.com";
}
</script>
Then, if the reason a particular user is saving the pages is to be able
look at them offline, he'll be foiled! Great way to achieve customer
satisfaction.

(wondering what whether a document has an images property has to do with
whether you use replace or href)
 
I

I.N. Galidakis

Brian said:
<snip>

If you really don't want them to look at your pages off-line, then why not
add javascript to redirect them to the real page (or your homepage) if the
url isn't what you expect?

Something like (not tested):

<script type="text/javascript" >
if ((document.location.hostname != "localhost") &&
(document.location.hostname != "ioannis.virtualcomposer2000.com"))
{
if (document.images)
top.location.replace("http://ioannis.virtualcomposer2000.com");
else
top.location.href = "http://ioannis.virtualcomposer2000.com";
}
</script>

Excellent! Many thanks for this. I haven't thought of it.

I will put this code (which works, btw) on my 2-3 pages which the users download
and view off-line.

Many thanks to all people who responded.
 
I

I.N. Galidakis

I.N. Galidakis said:
Excellent! Many thanks for this. I haven't thought of it.

I will put this code (which works, btw) on my 2-3 pages which the users
download and view off-line.

Many thanks to all people who responded.

Argh! WAIT! Code is copyrighted. I need to ask permission from Brian Cryer to
insert that code.

If it's ok Brian, I will include a &copy; inside the code.

Thanks again,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top