[TYPO3-dev] From JavaScript variable as PHP-variable

Bernd Wilke xoonsji02 at sneakemail.com
Sat Sep 23 13:38:19 CEST 2006


On Fri, 22 Sep 2006 14:28:33 +0300, Tapio Markula wrote
with subject "[TYPO3-dev] From JavaScript variable as PHP-variable":

> Hi
> 
> The script below is JavaScript
> and it fetch information about
> the URL of the page in certain frame.
> 
> 
> 	function getContentURL() {
> 	var message=top.content.location.href;
> 	if (top.content && message.indexOf("/typo3")==-1) {				
> 		if(message.indexOf("#")!=-1) {
> 			var indexValue = message.indexOf("#");
> 			message=message.substr(0,indexValue);
> 			}
> 		
> 		document.urlform.navurl.value=message;
> 		}
> 		document.urlform.navurl.value=message;
> 		';
> 		$thisJSCode.='
> 	}
> window.onload=getContentURL
> }
> 
> Is there any idea, howt I could get the JavaScript variable
> as PHP-variable in order to use with PHP-scripts.

when will you get that variable?

on building the page?

remember where and when PHP and javascript are executed:

The pagevisiter used his browser to see a page. The browser contacts the
webserver (maybe apache). that starts PHP, which builds some HTML-Data (it
may contain some javascript) which is transfered to the Browser.
Then the Browser computes the HTML and then executes the javascript.
At that moment there is no connection to the PHP which isn't working
anymore.

The only way to give Information to the PHP is on the page call: as POST-
or GET-Parameter. That means your Javascript can build/ fill a form which
is transferred on the NEXT pagecall. (or a GET-Param as addition to the
URL)

Bernd
-- 
----------------
Bernd Wilke     
Annweilerstr.20 
40229 Düsseldorf
0211/229 2800




More information about the TYPO3-dev mailing list