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

Tapio Markula tapio.markula at atwebteam.com
Sat Sep 23 15:18:42 CEST 2006


Bernd Wilke kirjoitti:
 > 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?

I would need that for filling a form field, which is generated by PHP.
The code above is for a form, which is generated with JavaScript
but I would have another form too.


 > 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.

ok

 > The only way to give Information to the PHP is on the page call: as POST-
 > or GET-Parameter.

or building some cookies

That means your Javascript can build/ fill a form which
 > is transferred on the NEXT pagecall.

that is too late into my purpose (concerns also cookies).

If I would use forms how to execute the form automatic?
onLoad?

But I got an idea. I can use as web-address a page, which has just some 
JavaScript and that page is immediately redirected to another address.
Presumably document write can create desired META-element in the 
HEAD-section.

I have two forms for shortcut frame
The upper is the default form for BE editing.
The lower gets web-address of the page including id.
Normally that works as link to FE page.
I just would need the id to the BE form.

Idea. You have on the frame below a FE page.
Clicking a link you could get two filled form, which you could
either edit in BE the same page or select another page either for
FE or BE editing.

No the only way is to use a redirected page. Cause some delay,
which might be irritating?

Tested that - doesn't work in MS IE

redirected address ../../../typo3/alt_shortcut.php?redirectURL=http//....

MS IE gets confused with param., which has as value http://...




More information about the TYPO3-dev mailing list