•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 455,976 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,797 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 6209 | Replies: 8 | Solved
![]() |
| |
•
•
Join Date: Nov 2007
Posts: 19
Reputation:
Rep Power: 1
Solved Threads: 0
hi,
i want to disable the parent window when i opened the child window using javascript and html.
i have written code like this.but its working only one time.any one knows pls help me in this situation.
s.html
<html>
<head>
<SCRIPT >
function popuponclick()
{
my_window = window.open("p.html",
"mySelect", "status=1,width=750,height=450,resizable=no");
//enableDisable();
}
</script>
</head>
<body>
<form name="formSelect">
<P>
<A HREF="#" onclick='popuponclick()' >show popup window</A><br>
</P>
</div>
</form>
</body>
</html>
p.html
<html>
<head>
<script language = javascript>
</script>
</head>
<body onBlur="self.focus()">
bbb
</body>
</html>
i want to disable the parent window when i opened the child window using javascript and html.
i have written code like this.but its working only one time.any one knows pls help me in this situation.
s.html
<html>
<head>
<SCRIPT >
function popuponclick()
{
my_window = window.open("p.html",
"mySelect", "status=1,width=750,height=450,resizable=no");
//enableDisable();
}
</script>
</head>
<body>
<form name="formSelect">
<P>
<A HREF="#" onclick='popuponclick()' >show popup window</A><br>
</P>
</div>
</form>
</body>
</html>
p.html
<html>
<head>
<script language = javascript>
</script>
</head>
<body onBlur="self.focus()">
bbb
</body>
</html>
Attach a function to the onclick and onfocus event handlers which would do something like this:
Here my_window is a global variable which holds the reference to the newly created popup window. It follows that as long as the child window is alive it will the one given focus.
javascript Syntax (Toggle Plain Text)
function focusChild() { if(my_window) my_window.focus(); }
Last edited by ~s.o.s~ : Nov 29th, 2007 at 1:06 pm.
I don't accept change. I don't deserve to live.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
It is working for me which means you are doing something wrong. Post the updated code with code tags. Read the announcements and site rules to know about them without which getting help might be a bit difficult.
I don't accept change. I don't deserve to live.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
•
•
Join Date: Nov 2007
Posts: 19
Reputation:
Rep Power: 1
Solved Threads: 0
hi,
thanks for giving the reply.u r not clear abt my task.i will explain u clearly.
i have one link in parent window.if i click that link i want to open one poup winodw(child window)this is first child window.In first child window i have one link if i click that link then another child window will be open. but both of the child windows the parent is same.
when i open the first child window then the parent should be disable .when i close the first child window then the parent window should be enable.(similar to window.showModalDialog).
In my code i am disabling the parent window after opening the first child window. from first child window i am opening another(second) child window. but the focus is always in my first child window only. when i open the second child window also foucs is gng to firt child window only. why becuase i have written the code like that.i know that my code is wrong.but i am not getting anything how to write that code. please u can help me in that.
my code is:
s.html(parent window)
<html>
<head>
<SCRIPT >
function popuponclick()
{
my_window = window.open("p.html","mySwap", "status=1,width=750,height=450,resizable=no,modal");
}
</script>
</head>
<body>
<P>
<A HREF="#" onclick='popuponclick()' >show popup window</A>
</P>
</body>
</html>
p.hmtl( first child window)
<html>
<head>
<script language = javascript>
function fcsOnMe(){
window.focus();
mytimer = setTimeout('fcsOnMe()');
}
function ppclickcun()
{
my_window = window.open("w.html","Swap", "status=1,width=750,height=450,resizable=no,modal");
}
</script>
</head>
<body onLoad = "mytimer = setTimeout('fcsOnMe()',50);">
<a href='#' onclick='ppclickcun()'>childwindowpopup</a>
</body>
</html>
w.html(2nd child window)
<html>
<head>
<script language = javascript>
</script>
</head>
<body>
ssss
</body>
</html>
i am waiting for u r reply.
Thanking you,
Swap.
thanks for giving the reply.u r not clear abt my task.i will explain u clearly.
i have one link in parent window.if i click that link i want to open one poup winodw(child window)this is first child window.In first child window i have one link if i click that link then another child window will be open. but both of the child windows the parent is same.
when i open the first child window then the parent should be disable .when i close the first child window then the parent window should be enable.(similar to window.showModalDialog).
In my code i am disabling the parent window after opening the first child window. from first child window i am opening another(second) child window. but the focus is always in my first child window only. when i open the second child window also foucs is gng to firt child window only. why becuase i have written the code like that.i know that my code is wrong.but i am not getting anything how to write that code. please u can help me in that.
my code is:
s.html(parent window)
<html>
<head>
<SCRIPT >
function popuponclick()
{
my_window = window.open("p.html","mySwap", "status=1,width=750,height=450,resizable=no,modal");
}
</script>
</head>
<body>
<P>
<A HREF="#" onclick='popuponclick()' >show popup window</A>
</P>
</body>
</html>
p.hmtl( first child window)
<html>
<head>
<script language = javascript>
function fcsOnMe(){
window.focus();
mytimer = setTimeout('fcsOnMe()');
}
function ppclickcun()
{
my_window = window.open("w.html","Swap", "status=1,width=750,height=450,resizable=no,modal");
}
</script>
</head>
<body onLoad = "mytimer = setTimeout('fcsOnMe()',50);">
<a href='#' onclick='ppclickcun()'>childwindowpopup</a>
</body>
</html>
w.html(2nd child window)
<html>
<head>
<script language = javascript>
</script>
</head>
<body>
ssss
</body>
</html>
i am waiting for u r reply.
Thanking you,
Swap.
> but both of the child windows the parent is same.
No, this isn't the case.
> when i open the first child window then the parent should be disable .when i close the first
> child window then the parent window should be enable
Though the above code works, it has some major problems.
◄ All the above files have a DOCTYPE declaration missing which is a bad thing causing the browser to go in quirks mode.
◄ Instead of directly attaching event listeners to event handlers, one should use addEventListener / attachEvent.
◄ Place all your Javascript in an external file instead of keeping it in each and every file.
◄ Make sure that you keep your tag names in lowercase.
No, this isn't the case.
> when i open the first child window then the parent should be disable .when i close the first
> child window then the parent window should be enable
<!-- s.html -->
<html>
<head>
<title>s.html</title>
<SCRIPT >
my_window = null;
function popuponclick() {
my_window = window.open("p.html","myP", "status=1,width=750,height=450,resizable=no,modal");
}
function check() {
if(my_window && !my_window.closed)
my_window.focus();
}
window.onload = function() {
window.name = "s.html";
}
</script>
</head>
<body onclick="check();" onfocus="check();">
<p>
<a href="#" onclick="popuponclick();">show popup window</a>
<br />
<a href="#" onclick="window.close();">close popup window</a>
</p>
</body>
</html> <!-- p.html -->
<html>
<head>
<title>p.html</title>
<script language = javascript>
my_window = null;
function popuponclick()
{
my_window = window.open("w.html","myW", "status=1,width=750,height=450,resizable=no,modal");
}
function check()
{
if(my_window && !my_window.closed)
my_window.focus();
}
window.onload = function() {
window.name = "p.html";
alert("Parent of p.html: " + opener.name);
}
</script>
</head>
<body onclick="check();" onfocus="check();">
<p>
<a href="#" onclick="popuponclick();">show popup window</a>
<br />
<a href="#" onclick="window.close();">close popup window</a>
</p>
</body>
</html><!-- w.html -->
<html>
<head>
<title>w.html</title>
</head>
<script type="text/javascript">
window.onload = function() {
alert("Parent of w.html: " + opener.name);
}
</script>
<body>
<p>
<a href="#">show popup window</a>
<br />
<a href="#" onclick="window.close();">close popup window</a>
</p>
</body>
</html>Though the above code works, it has some major problems.
◄ All the above files have a DOCTYPE declaration missing which is a bad thing causing the browser to go in quirks mode.
◄ Instead of directly attaching event listeners to event handlers, one should use addEventListener / attachEvent.
◄ Place all your Javascript in an external file instead of keeping it in each and every file.
◄ Make sure that you keep your tag names in lowercase.
I don't accept change. I don't deserve to live.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
•
•
Join Date: Oct 2008
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 1
•
•
•
•
> but both of the child windows the parent is same.
No, this isn't the case.
> when i open the first child window then the parent should be disable .when i close the first
> child window then the parent window should be enable
<!-- s.html --> <html> <head> <title>s.html</title> <SCRIPT > my_window = null; function popuponclick() { my_window = window.open("p.html","myP", "status=1,width=750,height=450,resizable=no,modal"); } function check() { if(my_window && !my_window.closed) my_window.focus(); } window.onload = function() { window.name = "s.html"; } </script> </head> <body onclick="check();" onfocus="check();"> <p> <a href="#" onclick="popuponclick();">show popup window</a> <br /> <a href="#" onclick="window.close();">close popup window</a> </p> </body> </html>
<!-- p.html --> <html> <head> <title>p.html</title> <script language = javascript> my_window = null; function popuponclick() { my_window = window.open("w.html","myW", "status=1,width=750,height=450,resizable=no,modal"); } function check() { if(my_window && !my_window.closed) my_window.focus(); } window.onload = function() { window.name = "p.html"; alert("Parent of p.html: " + opener.name); } </script> </head> <body onclick="check();" onfocus="check();"> <p> <a href="#" onclick="popuponclick();">show popup window</a> <br /> <a href="#" onclick="window.close();">close popup window</a> </p> </body> </html>
<!-- w.html --> <html> <head> <title>w.html</title> </head> <script type="text/javascript"> window.onload = function() { alert("Parent of w.html: " + opener.name); } </script> <body> <p> <a href="#">show popup window</a> <br /> <a href="#" onclick="window.close();">close popup window</a> </p> </body> </html>
Though the above code works, it has some major problems.
◄ All the above files have a DOCTYPE declaration missing which is a bad thing causing the browser to go in quirks mode.
◄ Instead of directly attaching event listeners to event handlers, one should use addEventListener / attachEvent.
◄ Place all your Javascript in an external file instead of keeping it in each and every file.
◄ Make sure that you keep your tag names in lowercase.
Thank u very much it really helps me a lot.
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- ratpoison... (Window and Desktop Managers)
- Open In New Window Php (PHP)
- blank pop-ups (Viruses, Spyware and other Nasties)
- JavaScript/DHTML newbie -- general questions (JavaScript / DHTML / AJAX)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: add text to images
- Next Thread: passing html input to js file???



Hybrid Mode