944,141 Members | Top Members by Rank

Ad:
Nov 29th, 2007
-1

disable parent window

Expand Post »
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>
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
smilyswapna10 is offline Offline
19 posts
since Nov 2007
Nov 29th, 2007
0

Re: disable parent window

Attach a function to the onclick and onfocus event handlers which would do something like this:
javascript Syntax (Toggle Plain Text)
  1. function focusChild()
  2. {
  3. if(my_window)
  4. my_window.focus();
  5. }
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.
Last edited by ~s.o.s~; Nov 29th, 2007 at 1:06 pm.
Super Moderator
Featured Poster
Reputation Points: 3241
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,873 posts
since Jun 2006
Nov 30th, 2007
0

Re: disable parent window

hi, this function is not working.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
smilyswapna10 is offline Offline
19 posts
since Nov 2007
Nov 30th, 2007
0

Re: disable parent window

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.
Super Moderator
Featured Poster
Reputation Points: 3241
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,873 posts
since Jun 2006
Dec 3rd, 2007
0

Re: disable parent window

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
smilyswapna10 is offline Offline
19 posts
since Nov 2007
Dec 3rd, 2007
0

Re: disable parent window

> 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

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <!-- s.html -->
  2.  
  3. <html>
  4. <head>
  5. <title>s.html</title>
  6. <SCRIPT >
  7. my_window = null;
  8. function popuponclick() {
  9. my_window = window.open("p.html","myP", "status=1,width=750,height=450,resizable=no,modal");
  10. }
  11.  
  12. function check() {
  13. if(my_window && !my_window.closed)
  14. my_window.focus();
  15. }
  16.  
  17. window.onload = function() {
  18. window.name = "s.html";
  19. }
  20. </script>
  21. </head>
  22. <body onclick="check();" onfocus="check();">
  23. <p>
  24. <a href="#" onclick="popuponclick();">show popup window</a>
  25. <br />
  26. <a href="#" onclick="window.close();">close popup window</a>
  27. </p>
  28. </body>
  29. </html>

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <!-- p.html -->
  2.  
  3. <html>
  4. <head>
  5. <title>p.html</title>
  6. <script language = javascript>
  7. my_window = null;
  8. function popuponclick()
  9. {
  10. my_window = window.open("w.html","myW", "status=1,width=750,height=450,resizable=no,modal");
  11. }
  12.  
  13. function check()
  14. {
  15. if(my_window && !my_window.closed)
  16. my_window.focus();
  17. }
  18.  
  19. window.onload = function() {
  20. window.name = "p.html";
  21. alert("Parent of p.html: " + opener.name);
  22. }
  23. </script>
  24. </head>
  25. <body onclick="check();" onfocus="check();">
  26. <p>
  27. <a href="#" onclick="popuponclick();">show popup window</a>
  28. <br />
  29. <a href="#" onclick="window.close();">close popup window</a>
  30. </p>
  31. </body>
  32. </html>

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <!-- w.html -->
  2.  
  3. <html>
  4. <head>
  5. <title>w.html</title>
  6. </head>
  7. <script type="text/javascript">
  8. window.onload = function() {
  9. alert("Parent of w.html: " + opener.name);
  10. }
  11. </script>
  12. <body>
  13. <p>
  14. <a href="#">show popup window</a>
  15. <br />
  16. <a href="#" onclick="window.close();">close popup window</a>
  17. </p>
  18. </body>
  19. </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.
Super Moderator
Featured Poster
Reputation Points: 3241
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,873 posts
since Jun 2006
Dec 4th, 2007
0

Re: disable parent window

hi,

thanks for sending the code.its working correctly to my requirement.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
smilyswapna10 is offline Offline
19 posts
since Nov 2007
Dec 7th, 2007
0

Re: disable parent window

hi ,

window.activeEditor._frame.execCommand(" JustifyCenter", false);

in the above script total editor text change in to center,

but i have to change only selected cursor line only

Thanking you,
swap
Reputation Points: 10
Solved Threads: 0
Newbie Poster
smilyswapna10 is offline Offline
19 posts
since Nov 2007
Nov 5th, 2008
0

Re: disable parent window

Click to Expand / Collapse  Quote originally posted by ~s.o.s~ ...
> 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

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <!-- s.html -->
  2.  
  3. <html>
  4. <head>
  5. <title>s.html</title>
  6. <SCRIPT >
  7. my_window = null;
  8. function popuponclick() {
  9. my_window = window.open("p.html","myP", "status=1,width=750,height=450,resizable=no,modal");
  10. }
  11.  
  12. function check() {
  13. if(my_window && !my_window.closed)
  14. my_window.focus();
  15. }
  16.  
  17. window.onload = function() {
  18. window.name = "s.html";
  19. }
  20. </script>
  21. </head>
  22. <body onclick="check();" onfocus="check();">
  23. <p>
  24. <a href="#" onclick="popuponclick();">show popup window</a>
  25. <br />
  26. <a href="#" onclick="window.close();">close popup window</a>
  27. </p>
  28. </body>
  29. </html>

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <!-- p.html -->
  2.  
  3. <html>
  4. <head>
  5. <title>p.html</title>
  6. <script language = javascript>
  7. my_window = null;
  8. function popuponclick()
  9. {
  10. my_window = window.open("w.html","myW", "status=1,width=750,height=450,resizable=no,modal");
  11. }
  12.  
  13. function check()
  14. {
  15. if(my_window && !my_window.closed)
  16. my_window.focus();
  17. }
  18.  
  19. window.onload = function() {
  20. window.name = "p.html";
  21. alert("Parent of p.html: " + opener.name);
  22. }
  23. </script>
  24. </head>
  25. <body onclick="check();" onfocus="check();">
  26. <p>
  27. <a href="#" onclick="popuponclick();">show popup window</a>
  28. <br />
  29. <a href="#" onclick="window.close();">close popup window</a>
  30. </p>
  31. </body>
  32. </html>

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <!-- w.html -->
  2.  
  3. <html>
  4. <head>
  5. <title>w.html</title>
  6. </head>
  7. <script type="text/javascript">
  8. window.onload = function() {
  9. alert("Parent of w.html: " + opener.name);
  10. }
  11. </script>
  12. <body>
  13. <p>
  14. <a href="#">show popup window</a>
  15. <br />
  16. <a href="#" onclick="window.close();">close popup window</a>
  17. </p>
  18. </body>
  19. </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.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
demudubabu is offline Offline
1 posts
since Oct 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: add text to images
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Usefull Prototype





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC