aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Appending the data in frame or popup window 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 "Appending the data in frame or popup window" Watch "Appending the data in frame or popup window" New topic
Author

Appending the data in frame or popup window

swapnil paranjape
Ranch Hand

Joined: May 15, 2005
Posts: 126
This is my file trial.js(extrenal js file)

function getstarttime()
{
var start = new Date();
var timestamp = start.getHours()+'.'+start.getMinutes()+'.'+start.getSeconds()+'.'+start.getMilliseconds();
return timestamp;
}

function getendtime()
{
var end = new Date();
var timestamp = end.getHours()+'.'+end.getMinutes()+'.'+end.getSeconds()+'.'+end.getMilliseconds();
return timestamp;
}

I want to write function writelog which will write the above starttime and endtime information in the frame or popup window .

Then in my html page i want to use this function like this...

var st = starttime()
alert("click ok alertbox1");
var et = endtime()
writelog(st,et);

I want to generate frame or popup showing startime, endtime using this writelog(st,et) function.

var st1 = starttime();
alert("click ok alertbox2");
var et1 = endtime();
writelog(st1,et1);
i want to append this starttime end time in the same window or frame below the above starttime endtimefor alertbox1.

i am facing problem here.i donot know how to append the data in the frame or popup window.

can somebody help me in writing the function writelog(startime,endtime)
this function should be generi like startime and endtime functions and can be used anywhere in html page to write starttime and endtime.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Why are you having so much trouble doing this? If I remember correctly his is your 5th time asking this.



Eric
swapnil paranjape
Ranch Hand

Joined: May 15, 2005
Posts: 126
i donot know how to append the data in the frame or popup window.
using your program i can write the data in the frame once.then next time i call the same function the previous data is overwritten by new data somthing like this

starttime:13.23.21.11
endtime:13.23.21.12

but i want to append my o/p after each call like this

starttime:13.23.21.11
endtime:13.23.21.12

starttime:13.23.31.41
endtime:13.23.31.42

starttime:13.24.21.11
endtime:13.24.21.12

on making function call the data is appended ..but using code u have provided the o/p is overwritten

so how should i do that?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
popUpId.document.body.innerHTML += "the string";

parent.frameName.document.body.innerHTML = "the String";

Eric
swapnil paranjape
Ranch Hand

Joined: May 15, 2005
Posts: 126
function getstarttime()
{
var start = new Date();
var timestamp = start.getHours()+'.'+start.getMinutes()+'.'+start.getSeconds()+'.'+start.getMilliseconds();
return timestamp;
}

function getendtime()
{
var end = new Date();
var timestamp = end.getHours()+'.'+end.getMinutes()+'.'+end.getSeconds()+'.'+end.getMilliseconds();
return timestamp;
}

function writelog(str,end)
{
document.write("<FRAMESET cols=70%,30%>")
document.write("<FRAME SRC=1.html name=left_frame>")
document.write(" <FRAME SRC=2.html name=right_frame> ")
document.write("</FRAMESET>")
var txt =str+'<br>'+end ;
top.frames["right_frame"].document.getElementsByTagName('body')[0].innerHTML=txt;

}
in 2.html i am writing the o/p to html page ..bot i am getting error
top.frames["right_frame"].document.getElementsByTagName STATING THAT its not a object or null how shud i go about this?
swapnil paranjape
Ranch Hand

Joined: May 15, 2005
Posts: 126
i want to call the writelog function in 1.html and once it is called the two frames shud appear .and right frame (2.html) will display o/p
Niki Nono
Ranch Hand

Joined: Mar 20, 2005
Posts: 256

top.frames["right_frame"].document.getElementsByTagName('body')[0].innerHTML=txt;


what does getElementsByTagName('body')[0] mean? u have multiple body tags???
why not just give document.body as eric has suggested?


Life called,so here I am.<br />Cheers<br />Niki.:-)
swapnil paranjape
Ranch Hand

Joined: May 15, 2005
Posts: 126
here are my three files.

file 1.html
<html>
<head>
<script language="JavaScript" src="trial.js">
</script>
<script language="JavaScript">

function calculate()
{
var time = getstarttime()
alert("click ok to continue");
var end = getendtime();
writelog(time,end);
}
</script>
</head>
<body bgcolor = "pink">
<script>
calculate();
</script>
</body>
</html>

file trail.js
function getstarttime()
{
var start = new Date();
var timestamp = start.getHours()+'.'+start.getMinutes()+'.'+start.getSeconds()+'.'+start.getMilliseconds();
return timestamp;
}

function getendtime()
{
var end = new Date();
var timestamp = end.getHours()+'.'+end.getMinutes()+'.'+end.getSeconds()+'.'+end.getMilliseconds();
return timestamp;
}

function writelog(str,end)
{
document.write('<FRAMESET cols="70%,30%">')
document.write('<FRAME SRC="1.html" name="left_frame">')
document.write('<FRAME SRC="2.html" name="right_frame">')
document.write('</FRAMESET>')
var txt =str+'<br>'+end ;
top.frames["right_frame"].document.getElementsByTagName('body')[0].innerHTML=txt;
}

file 2.html
<HTML>
<HEAD>

</HEAD>
<BODY>
<script language="JavaScript/text">
var str = ''
var etr = ''
document.write("the starttime is"+str);
document.write("the end time is"+etr);
</script>
</body>
</html>

the error i am getting is top.frames["right_frame"].document.getElementsByTagName is null or not a object...


why i am getting this error?
swapnil paranjape
Ranch Hand

Joined: May 15, 2005
Posts: 126
i need to have the separate window...frame...popup....
i want to display the o/p there.
actually i want generic functions.
now i can put this function as probes and get the information.
Means i want to put getstarttime() before any element ..getendtime() after the element and then use this function writelog() to diaplay data..i should be able to call this function anywhere in my page and create new page showing outut.
swapnil paranjape
Ranch Hand

Joined: May 15, 2005
Posts: 126
function output(url,begin ,end) //i am passing three parameters to this function
{
now here i want to a new window(may be frame or popup) and i want to write these parameters to this window when first function call is made.
}
now whenever next function calls are made to this function the function should be able to write in the same window opened by it in first call ..below the previous written data.

how should i do that?
please explain ...

thank you.
gajanan
for popup window i have wrtitten this ...plezzz explain how to write o/pin this popup?
var newwindow = '';

function popitup(url,begin,end)
{
if (!newwindow.closed && newwindow.location)
{
newwindow.location.href = url;
}
else
{
newwindow=window.open(url,'name','height=400,width=350');
if (!newwindow.opener) newwindow.opener = self;
}
if (window.focus) {newwindow.focus()}
return false;
}
 
Consider Paul's rocket mass heater.
 
subject: Appending the data in frame or popup window