Jump to content

[SOLVED] opening file with javascript and passing variables to php.... probably not.


Dragen

Recommended Posts

Okay, I know I'm gonna get loads of "it can't be done!" comments, but....

I've got a javascript which opens up a file in a new window.. now I would just use

<a href="mylink" target="_blank">

But I want to specify the width and height of the pop-up.

So this is what my javascript link looks like:

<a href="javascript:void(0)" onclick="window.open('help.php', 'newWindow', 'scrollbars=1,resizable=1,height=500,width=600');">

I can easily add more variables in the function to send to the opened page....

I know php is server side and javascript is client, but if the javascript is being outputted before the php, because it's opening the file... could I not somehow pass a variable from the javascript function to a php function?

Link to comment
Share on other sites

okay.. sorry.

 

I have some javascript which opens a file in a new window at the dimensions where it says

height=500,width=600

in the onclick.

 

What I want to do is use the javascript to open this file as I am already, but pass some variables to the page that php can read.

If I add an extra variable to the javascript function:

onclick="window.open('help.php', 'newWindow', 'scrollbars=1,resizable=1,height=500,width=600', '$myfunction');"

Can I somehow get the php in the new file to read the variable from the javascript function?

I thought that as the javascript is being used to open a file before the file has been accessed on the server I may be able to pass the variable to it at the same time as opening it....

 

 

Hopefully that makes more sense.

Link to comment
Share on other sites

as taith said, get/post/cookie are really your only options. Personally, if I want to pass info into a popup, just use the URL unless there's a reason why not:

 

so instead of just: help.php , you'd have help.php?var=value&anothervar=anothervalue

 

then just use $_GET to pick them up from within help.php itself.

Link to comment
Share on other sites

ya... javascript forcing $_POST... its not easy... but is doable, and no... javascript's window.open() doesnt pass variables, it only passes the configuration of the browser...

 

your best choice... is either setting the cookies, or using $_GET

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.