473,390 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,390 software developers and data experts.

Stuck with opend window (DOM)

Hello,

I'm new in Javascript and it seems I'm a bit stuck so if someone can help.
The problem is 4th button / function. I dont know how to talk to the opend
window, the thing with focus i wrote doesen't work so i didn't wrote code
for randomizeing location (this i know how to do).

Did i do something wrong?

window.opener works fine form the child window is there something similar
for control from parent window?

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function op(a,b)
{
window.open('first.html', 'first', 'width='+a+',height='+b);
}
function rresize()
{
var v = screen.width;
var h = screen.height;
var vx = Math.floor(Math.random()*1000);
var hx = Math.floor(Math.random()*1000);
if( vx v){vx = v;}
if( hx h){hx = h;}
op(vx,hx);
}
function rmove()
{
window.first.focus();
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<input type="button" value="open new window 350 x 200"
onClick="op(350,200)"></br>
<input type="button" value="open new window 1/2 width and height of screen"
onClick="op(screen.width/2,screen.height/2)"></br>
<input type="button" value="open new window radnom size"
onClick="rresize()"></br></br>
<input type="button" value="focus and random move opend window"
onClick="rmove()"></br>
</BODY>
</HTML>

Thank you!
May 11 '07 #1
2 1545
Lee
Nicholas said:
>
Hello,

I'm new in Javascript and it seems I'm a bit stuck so if someone can help.
The problem is 4th button / function. I dont know how to talk to the opend
window, the thing with focus i wrote doesen't work so i didn't wrote code
for randomizeing location (this i know how to do).

Did i do something wrong?
Yes, you tried guessing what might work, instead of reading a manual.
<script type="text/javascript">

var firstWindow;

function op(a,b)
{
firstWindow=window.open('first.html', 'first', 'width='+a+',height='+b);
}

function rresize()
{
var v = screen.width;
var h = screen.height;
var vx = Math.floor(Math.random()*1000);
var hx = Math.floor(Math.random()*1000);
if( vx v){vx = v;}
if( hx h){hx = h;}
op(vx,hx);
}

function rmove()
{
if(firstWindow) {
firstWindow.focus();
}
}

</SCRIPT>
--

May 11 '07 #2
ASM
Nicholas a écrit :
Hello,

I'm new in Javascript and it seems I'm a bit stuck so if someone can help.
The problem is 4th button / function. I dont know how to talk to the opend
window, the thing with focus i wrote doesen't work so i didn't wrote code
for randomizeing location (this i know how to do).

Did i do something wrong?

window.opener works fine form the child window is there something similar
for control from parent window?

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function op(a,b)
{
window.open('first.html', 'first', 'width='+a+',height='+b);
you have to give a JS name to your popup :

myPopUp = window.open('first.html','first','width='+a+',heig ht='+b);
}
function rresize()
{
var v = screen.width;
var h = screen.height;
var vx = Math.floor(Math.random()*1000);
var hx = Math.floor(Math.random()*1000);
if( vx v){vx = v;}
if( hx h){hx = h;}
op(vx,hx);
}
function rmove()
{
window.first.focus();
myPopUp.focus(); // window is de facto
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<input type="button" value="open new window 350 x 200"
onClick="op(350,200)"></br>
<input type="button" value="open new window 1/2 width and height of screen"
onClick="op(screen.width/2,screen.height/2)"></br>
<input type="button" value="open new window radnom size"
onClick="rresize()"></br></br>
<input type="button" value="focus and random move opend window"
onClick="rmove()"></br>
</BODY>
</HTML>

Thank you!


--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Contact : http://stephane.moriaux.perso.wanadoo.fr/contact
ASM = Aimable Stéphane Moriaux = Amateur Sasseur Merdouilles
May 11 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jawahar Rajan | last post by:
All, I have a printer friendly page that is opened when a user clicks a link on my page to get the printer friendly version, How ever when they close out the printer friendly version and return to...
1
by: Andi B | last post by:
Greetings all, thankyou for your help with the other things I posted about - but Im afraid I've another question: Is there a way I can get a document to resize the popup window it appears in...
5
by: Mike | last post by:
In my previous post, I wrote: > ... > GOAL: (very simple) Provide a hyperlink which, when clicked, > calls a javascript function which opens a new URL. > ... > PROBLEM: The following code...
6
by: news.versatel.de | last post by:
Hello NG, I am using javascript to open a new window like this: printpreview=window.open('printview.php','printprev','width=600,height=600'); The new window has a layer called preview: ...
29
by: wayne | last post by:
Hey there... I'm having some problems passing url parameters with an open.window command. I'm not terribly familiar with java script but here is the code below. When executed it opens the...
5
by: Hemanth | last post by:
Hello there, I'm running a script that opens a popup window (which is basically a form with checkboxes and a submit button). When I click the submit button I want to run a PHP script and target...
6
by: Luke Matuszewski | last post by:
As in topic... has anyone used it ? I tried to use it but i guess i failed... here is a code: <html> <head> <title></title> <script type="text/javascript"> function closedWin() {...
22
by: stephen | last post by:
I have created an order form that users javascript to create a new html document when the customers clicks the "print page" button. Once the new document has been created it then prints the...
26
by: yb | last post by:
Hi, Is there a standard for the global 'window' object in browsers? For example, it supports methods such as setInterval and clearInterval, and several others. I know that w3c standardized...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.