All pastes #28840 Raw Edit

dumb4ever

public javascript v1 · immutable
#28840 ·published 2005-11-15 21:09 UTC
rendered paste body
//------------------------------------------------------------------------------/*	Function:	goBack	Arguments:	void	Return:		void	Description:	Tell the browser to backup in its history*/function goBack() {	window.history.back();}//------------------------------------------------------------------------------/*	Function:	goHere	Arguments:	String:		URL Address to tell browser to go to	Return:		void	Description:	Tell the browser to go to a specific URL*/function goHere(url) {	window.location = url;}function navigate( url ) {	window.location = url;}//------------------------------------------------------------------------------/*	Function:	setCookie	Arguments:	String:		Name of the cookie			[dynamic]:	Value of the cookie			String:		Domain path to store the cookie with			String:		Timestamp for the cookie to expire on	Return:		void	Description:	Set a cookie*/function setCookie(name, value, path, expires) {	//---	value = escape(value); // encode value	expires = (expires)?"; expires=" + expires: "";	path = (path)?"; path=" + path: "";	document.cookie = name + "=" + value + expires + path;	//---}//------------------------------------------------------------------------------/*	Function:	getCookie	Arguments:	String:		Name of the cookie	Return:		void	Description:	Get a cookie by name*/function getCookie(name) {	//---	startIndex = document.cookie.indexOf(name + "=");	if(startIndex == -1) return null;	startIndex = startIndex + name.length + 1;	endIndex = document.cookie.indexOf(";", startIndex);	if(endIndex == -1) {		endIndex = document.cookie.length;	}	//---	return unescape(document.cookie.substring(startIndex, endIndex));}//------------------------------------------------------------------------------/*	Function:	restoreScrollPosition	Arguments:	void	Return:		void	Description:	Restore the scroll position of the last page after			clicking through a link.*/function restoreScrollPosition() {	//---	vars = getCookie("scroll_position");	if(!vars)		return null;	xString = vars.substring(0, vars.indexOf("-"));	yString = vars.substring(vars.indexOf("-") + 1, vars.length);	// scroll to position	window.scrollTo(parseInt(xString), parseInt(yString));	//---}//------------------------------------------------------------------------------/*	Function:	saveScrollPosition	Arguments:	void	Return:		void	Description:	Save the current page's scroll position*/function saveScrollPosition() {	//---	x = (document.all)?document.body.scrollLeft:window.pageXOffset;	x = (x)? x: document.documentElement.scrollLeft;	y = (document.all)?document.body.scrollTop:window.pageYOffset;	y = (y)? y: document.documentElement.scrollTop;	setCookie("scroll_position", x + "-" + y, "", "");	//---}//------------------------------------------------------------------------------