aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes sending parameters in js Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "sending parameters in js" Watch "sending parameters in js" New topic
Author

sending parameters in js

swapnil paranjape
Ranch Hand

Joined: May 15, 2005
Posts: 126
hi
i am trying to send the parameters to the popup window from js function.
Now this is my js function and i am trying to send parameters to popup.

var newwindow = '';
function popitup(url,st,ed)
{
newwindow=window.open(url,'name','height=400,width=350');
var txt = st+'<br>'+ed
newwindow.document.body.innerHTML += txt;
}

this is the call to the function
popitup("\main.html","10","20");

This is javascript in my popup window(html) page here i want to display parameters....

var begin = ' ';
var end = ' ';
document.write(begin)
document.write("<br>")
document.write(end)
document.write("<br>")


but this is not working......
whats the problem?how should i send the parameters?i want to write that paramets in popup window...
swapnil paranjape
Ranch Hand

Joined: May 15, 2005
Posts: 126
i got the solution for my above problem...now this is new question i want to ask......
i have this function
var newwindow = '';
function popitup(url,st,ed)
{

newwindow=window.open(url,'name','height=400,width=350');

var txt = st+'<br>'+ed

newwindow.document.getElementsByTagName('body')[0].innerHTML=txt;


}
AND THE CODE WRITTEN IN THE BODY IS

alert("Click OK ");
popitup("\trial.html","10","20");
alert("click ok alert2");
popitup("\trial.html","30","40");

now here 10 20 first gets displayed in popup window and then 30 40 gets diaplayed in popup window overwriting the 10 20
but i want to display both outputs in one window one below other...
how can i do this?
please help me.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You need to see if the window is open


Eric
swapnil paranjape
Ranch Hand

Joined: May 15, 2005
Posts: 126
I am using this code.....and checking weather the window is open or not and trying to append the o/p but still i am not getting o/p as expected....


this is my function

var newwindow = '';
function popitup(url,st,ed)
{
if (!newwindow.closed && newwindow.location)
{
newwindow.location.href = url;
}
else
{
newwindow=window.open(url,'name','height=400,width=400');
if (!newwindow.opener) newwindow.opener = self;
}

if (window.focus) {newwindow.focus()}

var txt st+'<br>'+ed
newwindow.document.getElementsByTagName('body')[0].innerHTML=txt;
}

still if i make consecutive function call like this ...

popitup(url,10,20)
popitup(url,30,40)

the output is :
first 10 20 gets displayed and then 30 40 is displayed in the same window overwriting 10 20.....i dont want that...i want 10 20 followed by 30 40.

how to do that?even i have made attempt to make txt global (var txt ='')...but that doent work...
please help me....
thank you

i would also like to know how to use "superimposed" div instead of a popup in this case...to display the o/p
[ July 26, 2005: Message edited by: swapnil paranjape ]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
look how you changed this line from your orginal and what I posted:

newwindow.document.getElementsByTagName('body')[0].innerHTML=txt;

Eric
swapnil paranjape
Ranch Hand

Joined: May 15, 2005
Posts: 126
thank you!!! i got the answer for the problem...+= was required rhater than = ...thank you....
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: sending parameters in js