Go to Post You can't guarantee outcomes -- only effort. If your team did its best, be satisfied. - Rick TYler [more]
Home
Go Back   Chief Delphi > Technical > IT / Communications > Website Design/Showcase
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-06-2003, 22:14
Trashed20's Avatar
Trashed20 Trashed20 is offline
Boom, Shawalala Boom!
#0862 (PCEP Lighting)
 
Join Date: Jan 2002
Location: Canton, MI
Posts: 528
Trashed20 will become famous soon enough
Send a message via AIM to Trashed20
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?
__________________
Where has all the fun gone?
  #2   Spotlight this post!  
Unread 02-06-2003, 22:33
jonathan lall's Avatar
jonathan lall jonathan lall is offline
Registered User
FRC #2505 (The Electric Sheep; FRC #0188 alumnus)
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: Toronto, Canada
Posts: 547
jonathan lall has a reputation beyond reputejonathan lall has a reputation beyond reputejonathan lall has a reputation beyond reputejonathan lall has a reputation beyond reputejonathan lall has a reputation beyond reputejonathan lall has a reputation beyond reputejonathan lall has a reputation beyond reputejonathan lall has a reputation beyond reputejonathan lall has a reputation beyond reputejonathan lall has a reputation beyond reputejonathan lall has a reputation beyond repute
Send a message via MSN to jonathan lall
If I follow correctly, yes certainly, but I wouldn't know how.

Brrrrrrrrandon!!
__________________

  #3   Spotlight this post!  
Unread 02-06-2003, 22:42
Jack's Avatar
Jack Jack is offline
FIRST Scouting Network
AKA: Andrew Schenk
FRC #0201 (The FEDS)
Team Role: Alumni
 
Join Date: Feb 2002
Rookie Year: 2002
Location: Rochester Hills
Posts: 643
Jack is a jewel in the roughJack is a jewel in the roughJack is a jewel in the rough
Send a message via AIM to Jack
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
__________________
Team 201 - 2003 Great Lakes Semifinalists & 2003 Archimedes Division Finalists :|: Webmaster of www.feds201.com -> FBI Scouting
Winner of The 2003 ChiefDelphi Web Award for: User That Started The Most Non Chit Chat Threads
Winner of: 2003 FIRST Ventures with 5451.68 End Points

All about me: http://knehcsa.vze.com
**Check out the New FIRST Scouting Network**
  #4   Spotlight this post!  
Unread 02-06-2003, 23:12
Trashed20's Avatar
Trashed20 Trashed20 is offline
Boom, Shawalala Boom!
#0862 (PCEP Lighting)
 
Join Date: Jan 2002
Location: Canton, MI
Posts: 528
Trashed20 will become famous soon enough
Send a message via AIM to Trashed20
Quote:
Originally posted by Jack
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
sorta....

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.
__________________
Where has all the fun gone?
  #5   Spotlight this post!  
Unread 03-06-2003, 00:09
Brandon Martus's Avatar Unsung FIRST Hero
Brandon Martus Brandon Martus is offline
busy.
AKA: B. Slash Kamen
no team
 
Join Date: May 2001
Rookie Year: 1998
Location: Nevada, TX USA
Posts: 5,271
Brandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond repute
Send a message via ICQ to Brandon Martus Send a message via AIM to Brandon Martus Send a message via Yahoo to Brandon Martus
here we go:
(note: this is not tested, this is pseudo-code to get you going)

Code:
<!--  somewhere up top in 'head' -->
<script language="JavaScript">
<!-- //
   function sendWithTimestamp(url) {
      timestamp = Get.The.Time.Stamp; // <-- said pesudo-code.  :)
      url = url + "&time=" + timestamp;
      window.location(url);  // <-- this may not be right, I forget exactly.
   }
-->
</script>

...
<!-- then down in the body -->

<a href="javascript:sendWithTimestamp('http://lightningrobotics.com/?do=news');">news</a>
Hope my near-sleep jabber makes any sense & gets you going in the right direction. You may need to make a function to get the timestamp in JavaScript... my book's at work and I'm too lazy to go search for the JS Time functions. I have to leave something for you to do, eh?
__________________
Brandon Martus
e-mail
  #6   Spotlight this post!  
Unread 03-06-2003, 06:08
Trashed20's Avatar
Trashed20 Trashed20 is offline
Boom, Shawalala Boom!
#0862 (PCEP Lighting)
 
Join Date: Jan 2002
Location: Canton, MI
Posts: 528
Trashed20 will become famous soon enough
Send a message via AIM to Trashed20
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...
__________________
Where has all the fun gone?
  #7   Spotlight this post!  
Unread 03-06-2003, 09:08
seanwitte seanwitte is offline
Registered User
None #0116
Team Role: Engineer
 
Join Date: Nov 2002
Location: Herndon, VA
Posts: 378
seanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant future
Send a message via AIM to seanwitte
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">
	<!--
		// return the current timestamp as a string
		function currentTimestamp()
		{
			var now = new Date();
			var ts = new Array(	
				now.getFullYear().toString(),
				now.getMonth().toString(),
				now.getDay().toString(),
				now.getHours().toString(),
				now.getMinutes().toString(),
				now.getSeconds().toString())
			var i;
			var retval = '';
			
			//pad one-digit values to two and concatenate 			
			//the order is yyyymmddhhnnss
			for (i=0; i<ts.length; i++)
			{
				if (ts[i].length < 2) ts[i] = '0' + ts[i];
				retval += ts[i];
			}
			return (retval);
		}	
	
		//append the current timestamp to a url and redirect
		function sendWithTimestamp(url)
		{
			// check url for a ?
			if (url.indexOf('?') >= 0) url += '&';
			else url += '?';
			
			//build the url
			url += 'time=' + escape(currentTimestamp());
			document.location.href = url;			
		}			
	//-->
	</SCRIPT>
Usage (the bulletin board software injects a space in "JavaScript", so you'll need to change it in the anchor tag):

Code:
<A HREF="javascript:sendWithTimestamp('mypage.php');">MyPage</A>
  #8   Spotlight this post!  
Unread 03-06-2003, 09:58
Joel J's Avatar
Joel J Joel J is offline
do you..
no team
 
Join Date: May 2001
Rookie Year: 2000
Location: San Jose, CA
Posts: 1,445
Joel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond repute
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.
__________________
Joel Johnson

Division By Zero (229) Alumni, 2003-2007
RAGE (173) Alumni, 1999-2003

Last edited by Joel J : 03-06-2003 at 10:02.
  #9   Spotlight this post!  
Unread 03-06-2003, 10:13
Brandon Martus's Avatar Unsung FIRST Hero
Brandon Martus Brandon Martus is offline
busy.
AKA: B. Slash Kamen
no team
 
Join Date: May 2001
Rookie Year: 1998
Location: Nevada, TX USA
Posts: 5,271
Brandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond repute
Send a message via ICQ to Brandon Martus Send a message via AIM to Brandon Martus Send a message via Yahoo to Brandon Martus
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
if ($timestamp==1) {
   $time = time();
}

// continue as planned..

?>
__________________
Brandon Martus
e-mail
  #10   Spotlight this post!  
Unread 03-06-2003, 21:20
HFWang's Avatar
HFWang HFWang is offline
Registered User
AKA: DarkWulf
#0115
Team Role: Webmaster
 
Join Date: Jan 2003
Location: Cupertino
Posts: 177
HFWang will become famous soon enough
Send a message via ICQ to HFWang Send a message via AIM to HFWang
I'd peresonally do it a different way... the link anyway...

Code:
<A
  HREF="mypage.php"
  onClick="
   window.location = this.href + sendWithTimestamp('mypage.php');
   return false;
  ">MyPage</A>
it makes opening in a new window/tab not break...

(spaced to be more readable. remove spaces as needed. :-D)
  #11   Spotlight this post!  
Unread 04-06-2003, 11:18
seanwitte seanwitte is offline
Registered User
None #0116
Team Role: Engineer
 
Join Date: Nov 2002
Location: Herndon, VA
Posts: 378
seanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant future
Send a message via AIM to seanwitte
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>
<HEAD>
<SCRIPT LANGUAGE="Javascript">
	<!--
		// return the current timestamp as a string
		function currentTimestamp()
		{
			var now = new Date();
			var ts = new Array(	
				now.getFullYear().toString(),
				now.getMonth().toString(),
				now.getDay().toString(),
				now.getHours().toString(),
				now.getMinutes().toString(),
				now.getSeconds().toString())
			var i;
			var retval = '';
			
			//pad one-digit values to two and concatenate 			
			//the order is yyyymmddhhnnss
			for (i=0; i<ts.length; i++)
			{
				if (ts[i].length < 2) ts[i] = '0' + ts[i];
				retval += ts[i];
			}
			return (retval);
		}	
	
		//update a querystring value in a URL or append 
		//it to the set if it does not already exist.
		function setQuerystringElement(url, element, value)
		{
			var newUrl = url;				
			var params = url.split('?');
			var param;
			var i;
			var found = false;
			
			//params will have either one or two entries, where
			//entry 0 if the base URL and entry 1 is the querystring
			if (params.length == 1) 
			{
				//url has no querystring, so just append element
				return newUrl += '?' + element + '=' + escape(value);
			}
			else
			{
				//save the base url from up above
				newUrl = params[0];				
				
				//divide the querystring into name/value pairs
				params = params[1].split('&');
				for (i=0; i<params.length; i++)
				{
					//divide each pair into a name and value
					param = params[i].split('=');					
					if (param[0].toLowerCase() == element.toLowerCase())
					{
						//update the value of the element 
						param[1] = value;
						found = true;
					}
					//append the parameter to the URL
					newUrl += (i == 0) ? '?' : '&';
					newUrl += param[0] + '=' + escape(param[1]);
				}				
				
				//if the element was not already in the URL, add it
				if (!found) newUrl += '&' + element + '=' + escape(value);									
			}			
			return (newUrl);	
		}		
	//-->
	</SCRIPT>
</HEAD>
<BODY>
<A HREF="temp.html" target="_blank" onclick="javascript:this.href=setQuerystringElement(this.href, 'time', currentTimestamp()); return true;">Link</A>
</BODY>
</HTML>
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 01:45.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi