![]() |
Javascript onclick link concatination
hehe, as if the title wan't complicated enought. Ok, i know you can do javascript actions via the onClick command. Is it possible to have the hyperlink (ex http://lightningrobotics.com/?do=news) dynamically change to the same url plus a "&time=(timestamp)" and then transport you to that page. the timestamp would have to be made via php in the javascript at the execution of the javascript. is it possible?
|
If I follow correctly, yes certainly, but I wouldn't know how. :rolleyes:
Brrrrrrrrandon!! |
yes.. if i get what you're saying correctly...
Here's what you'd need: (be sure the file gets parsed by php ;)) href="<?php echo "http://lightningrobotics.com/?do=news&".time(); ?>" that should do it :) |
Quote:
that would create all the links with the timestamp of initial parsing. So you could wait 5 minutes and have the timestamp be 5 minutes old. I need the timestamp right when you click the link. so you click the link (your mouse is still down) the timestamp is thrown in (you let go) and you go to the new url. |
here we go:
(note: this is not tested, this is pseudo-code to get you going) Code:
<!-- somewhere up top in 'head' --> |
that should work. I actually had a dream about this last night in which i just had the date ammended at the top of the standard page that had something like this:
if (!&GET[time]){ $timestamp=time; put url thingie here and add time do a http redirrect thingie to new url with timestamp } i think yours will work better if i can program figure out the rest. more efficient anyway. i'll work on it later tonight but right now i have to ge some skoolin for the last 2 days of my senioryear, yay... |
This'll work. You can modify the currentTimestamp() function to fit whatever format you want to use.
script block for the header: Code:
<SCRIPT LANGUAGE="Javascript">Code:
<A HREF="javascript:sendWithTimestamp('mypage.php');">MyPage</A> |
An observation that may change things: when javascript returns a timestamp, is it not based on the clock of the user's computer, which may or may not be the same as the clock on the server to which the link is directing? It is entirely possible that this is your goal, but I just thought I would point that out.
|
True.
You may want to send a flag to the link you are going to, and let the destination page make the timestamp. Code:
<a href="mypage.php?timestamp=1">My Page</a>Code:
<?php |
I'd peresonally do it a different way... the link anyway...
Code:
<A(spaced to be more readable. remove spaces as needed. :-D) |
nice
I didn't even think of that, you're completely right. If you have links targeting a frame or another window you don't want to lose that functionality. You can use a generalized function that sets a querystring value in a URL to do it and use it anywhere. Something like this:
Code:
<HTML> |
| All times are GMT -5. The time now is 01:45. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi