PDA

View Full Version : /big1.JPG?'+newDate().getTime() need help please



nospoony
09-27-2006, 10:21 AM
Hello all,

I'm new to javascript and new to this forum, and it would be nice if someone could help me.

I have a small problem.



Code:
<a href="javascript:popBeeld('aanbieding/boeket/big1.JPG?'+newDate().getTime()','Boeket v/d Week')">
It isn't working, can someone tell me what's wrong with this code?

the function popBeeld is working though.


Thanks a ton in advance

djr33
09-27-2006, 10:26 AM
Hmm...
You could try
<a href="#" onClick="PopBeeld(........)">

Though, it might be the code after that. (And that would give you a # at the end of the url bar after clicking the link.)


Ah, now I see it.

In javascript, the way to add multiple parts together is the plus sign-- +.

'something'+function()+variable+'stuff'.

You need to replace the dots and/or runon parts with a +.

+newDate().getTime()
should be:
+newDate()+getTime()+

However, I'm not sure about the dot. I don't do JS too much, and I use php, which does use a dot to combine parts. I know JS uses a + instead, but it might try to add the outputs of the functions together, since both will be numbers.
Just play with that and see if you can get it to work.

mwinter
09-27-2006, 10:59 AM
<a href="javascript:&#112;opBeeld('aanbieding/boeket/big1.JPG?'+newDate().getTime()','Boeket v/d Week')">

Have you considered that if scripting is disabled, that image will be inaccessible to the user?



<a href="aanbieding/boeket/big1.JPG" onclick="popBeeld(this.href, 'Boeket v/d Week'); return false;">

If you are trying to prevent caching by appending a number to the URL, first think if you really need to do that (caching is your friend - only disable it if absolutely necessary), and second, do it from the server.



the function popBeeld is working though.

Perhaps, though it still would have been nice to know what the arguments for that function mean. For example, if the second argument was the name for a new window, you'd have problems because any characters beyond letters, numbers, and underscores generally aren't well-received.

Mike