By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,442 Members | 1,327 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,442 IT Pros & Developers. It's quick & easy.

problems loading images...

P: n/a
I feel like a complete fool! I should know the answer to the Q:

How do I load an image with JS and replace the default image?

Some background: My final objective is to have a web site where it
is VERY difficult to copy images off the site. The first thing I
was going to do was force folks to turn on JavaScript so that I
could disable the right click pop up menu. To force this, I thought
I would have all the default images say that JavaScript is required
to view the images. The problem is that I cannot figure out for the
world in me how to load the good image. The page can be found here:

http://www.miltonstreet.com/index2.html

here are the code snips:
------------------------------------------------
[snip]
<body bgcolor="#FFFFFF">
<script language="JavaScript1.1">
<!--
TheImage = new Image();
TheImage.src = "images/RunningTheLine.jpg";
HomepageImage = document.images['hpImage'];
HomepageImage.src = TheImage.src;
//-->
</script>

[snip]

<img name="hpImage" src="images/njs-228x280.jpg" width="274"
height="336" border="0">
------------------------------------------------

Sam
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Lee
Sam Carleton said:

I feel like a complete fool! I should know the answer to the Q:

How do I load an image with JS and replace the default image?

Some background: My final objective is to have a web site where it
is VERY difficult to copy images off the site. The first thing I
was going to do was force folks to turn on JavaScript so that I
could disable the right click pop up menu. To force this, I thought
I would have all the default images say that JavaScript is required
to view the images.


You can't disable the right click menu reliably. Certainly
not in all browsers. If your page contains the URL of the
actual images, I can view the source and copy the URL into
the browser's location field. If I didn't feel like doing
that, I could simply do a screen capture, or copy the images
out of my cache.

Jul 20 '05 #2

P: n/a
Sam Carleton <sc**************@miltonstreet.com> writes:
I feel like a complete fool! I should know the answer to the Q:

How do I load an image with JS and replace the default image?
What you have should work *if* it is executed after the *image* tag has
been parsed.

<img id="hpImage" src="images/njs-228x280.jpg"
style="width:274px,height:336px,border:none">
<script type="text/javascript">
var HomepageImage = document.images['hpImage'];
HomepageImage.src = "images/RunningTheLine.jpg";;
</script>

There is no need for "TheImage"
Some background: My final objective is to have a web site where it
is VERY difficult to copy images off the site.
Give up. There is about a million ways to get it.
The first thing I was going to do was force folks to turn on
JavaScript so that I could disable the right click pop up menu.
Doesn't work in my browser. Doesn't prevent me from turning JS off
after the page has loaded. Doesn't stop me from using "Save with
imags". Doesn't stop me from finding the URL in the JS and loading
the image directly. Doesn't stop me from using a TCP snooper with
connection streaming to save the image.
To force this, I thought I would have all the default images say
that JavaScript is required to view the images. The problem is that
I cannot figure out for the world in me how to load the good image.


So your page only works with Javascript available, only because you
want to protect your images (which doesn't work). Since not all
browsers *can* turn Javascript on, some people can't use your page.

Your page would be better and more user friendly if you spend your
energy on making it more accessible, not less.

Oh yes, and validate your code. You'll probably be surpriced.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.