landril
05-26-2005, 09:11 AM
Some comment about the code:
-This code work with Firefox/Mozilla
-The Source page contain all Javascript code.
-If the object is created in the source page, it work with IE.
-The problem is the line: var test = new opener.window.popup()(object can't be instancied??).
-The popup object with the function reload() must change the value of a span in opener.window.
Source Page Code:
<html>
<head>
<script language="javascript" type="text/javascript">
/*Function to open a center POPUP*/
function open_center_popup(url,name,width,height,options)
{
var top=(screen.height-height)/2;
var left=(screen.width-width)/2;
window.open(url,name,"top="+top+",left="+left+",width="+width+",height="+height+","+options);
}
/****************************************************************************************/
/*POPUP Object*/
function popup() {
this.id = "99999";
this.txt = "ZZZZZZ";
this.reload = function(){
field = document.getElementById(this.id);
field.innerHTML = this.txt;
}
this.talk = function() {
document.write( "TEST" );
}
}
popup.prototype.setId = function(id) {
this.id = id;
}
popup.prototype.setText = function(txt) {
this.txt = txt;
}
/*End POPUP object*/
/******************************************************************************************/
</script>
</head>
<body>
<script language="javascript" type="text/javascript">
var test = new popup();
var test2 = new popup();
document.write(" Init Value for Id: " + test.id + " Init Value for Txt: " + test.txt);
test.setId("textarea");
test.setText("Chercq");
document.write("</br> Value after Set for Id: " + test.id + " Value after Set for Txt: " + test.txt + "</br>");
</script>
<span id="textarea">DefaultValue</span>
<a href='#'onClick="javascript:test.reload()">Change</a>
</br>
<a href='#'onClick="open_center_popup('popupB.html','popup',590,475,'scrollbars=yes')">GoToPopup</a>
</body>
</html>
Popup source Page
<html>
<head>
<script language="javascript" type="text/javascript">
</script>
</head>
<body>
<script language="javascript" type="text/javascript">
var test = new opener.window.popup();/*Here the object is create with a method from source page*/
document.write(" Init Value for Id: " + test.id + " Init Value for Txt: " + test.txt);
test.setId("textarea");
test.setText("TXTVALUE");
document.write("</br> Value after Set for Id: " + test.id + " Value after Set for Txt: " + test.txt + "</br>");
</script>
<a href='#'onClick="javascript:test.reload();window.close();">Change</a>
</body>
</html>
Thx for help.
-This code work with Firefox/Mozilla
-The Source page contain all Javascript code.
-If the object is created in the source page, it work with IE.
-The problem is the line: var test = new opener.window.popup()(object can't be instancied??).
-The popup object with the function reload() must change the value of a span in opener.window.
Source Page Code:
<html>
<head>
<script language="javascript" type="text/javascript">
/*Function to open a center POPUP*/
function open_center_popup(url,name,width,height,options)
{
var top=(screen.height-height)/2;
var left=(screen.width-width)/2;
window.open(url,name,"top="+top+",left="+left+",width="+width+",height="+height+","+options);
}
/****************************************************************************************/
/*POPUP Object*/
function popup() {
this.id = "99999";
this.txt = "ZZZZZZ";
this.reload = function(){
field = document.getElementById(this.id);
field.innerHTML = this.txt;
}
this.talk = function() {
document.write( "TEST" );
}
}
popup.prototype.setId = function(id) {
this.id = id;
}
popup.prototype.setText = function(txt) {
this.txt = txt;
}
/*End POPUP object*/
/******************************************************************************************/
</script>
</head>
<body>
<script language="javascript" type="text/javascript">
var test = new popup();
var test2 = new popup();
document.write(" Init Value for Id: " + test.id + " Init Value for Txt: " + test.txt);
test.setId("textarea");
test.setText("Chercq");
document.write("</br> Value after Set for Id: " + test.id + " Value after Set for Txt: " + test.txt + "</br>");
</script>
<span id="textarea">DefaultValue</span>
<a href='#'onClick="javascript:test.reload()">Change</a>
</br>
<a href='#'onClick="open_center_popup('popupB.html','popup',590,475,'scrollbars=yes')">GoToPopup</a>
</body>
</html>
Popup source Page
<html>
<head>
<script language="javascript" type="text/javascript">
</script>
</head>
<body>
<script language="javascript" type="text/javascript">
var test = new opener.window.popup();/*Here the object is create with a method from source page*/
document.write(" Init Value for Id: " + test.id + " Init Value for Txt: " + test.txt);
test.setId("textarea");
test.setText("TXTVALUE");
document.write("</br> Value after Set for Id: " + test.id + " Value after Set for Txt: " + test.txt + "</br>");
</script>
<a href='#'onClick="javascript:test.reload();window.close();">Change</a>
</body>
</html>
Thx for help.