Saturday, July 14, 2007

Posting dynamic data to a popup page

It's a common need to pass some JavaScript dynamically formatted data to a pop up page, this can be easy as you just need to append data to the URL of the pop up and open it using or simply by setting the src property of an anchor element, this is a get request.

But if the data is too big to be put in the query string (2kb+), or if you want to make it harder for the user to see and modify the passed parameters, you'll need to post this data.

this JavaScript function makes the job, I post the string ("real long data").

function PostToPopup()

var hdn= document.createElement("Input");

var frm= document.createElement("Form");"popup";


hdn.value="real long data";


You can read this value in the popup from the request..this is an ASP.NET example:

1 comment:

Wright Petter said...

Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer learn from Javascript Training in Chennai . or learn thru Javascript Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry. JavaScript Training in Chennai