Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #11 (permalink)  
Old September 27th, 2004, 12:22 PM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Elisabeth,

When you set a function to be called with setTimeout(), it get's called in the context of the current window, not where you originally set it in your code, therefore any variables / methods etc you want to access at that point need to be globally available.

Best regards,

Chris



Reply With Quote
  #12 (permalink)  
Old September 27th, 2004, 12:36 PM
Authorized User
 
Join Date: Feb 2004
Location: , , .
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, the problem is that it does not entirely work.
If I click on the first help field (that would call the explain functio), the 1st popup page appears.
Now, I click on the 2nd help field (which is longer than the first one, so I call the explain1 function).

RESULT: Only one of the two popup pages is automatically closed.!!!


Listen, I have defined 2 help popup pages (I am sure there is a better way of doing it but I don't know it). The reason I have done that is that I need the message to fit the popup page.... so I have defined 2 identical popup pages with 2 different heights!.
Now, here is what I have:

<script....>
var newwin;
var newwin1;

 function explain(msg)
{
newwin = window.open('', 'popUp1',"top=150,left=150,height=180,width=325,lo cation....setTimeout('newwin.close()', 60000);
newwin.focus();
....
}

function explain1(msg)
{
newwin1 = window.open('', 'popUp1',"top=150,left=150,height=180,width=325,lo cation....
setTimeout('newwin1.close()', 60000);
newwin1.focus();

...
}



Reply With Quote
  #13 (permalink)  
Old September 27th, 2004, 12:41 PM
Authorized User
 
Join Date: Feb 2004
Location: , , .
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually it is always newwin that is automatically closed!

Reply With Quote
  #14 (permalink)  
Old September 27th, 2004, 01:58 PM
Authorized User
 
Join Date: Feb 2004
Location: , , .
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Do you know what could be wrong?

Reply With Quote
  #15 (permalink)  
Old September 28th, 2004, 03:40 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

What you posted works fine for me, but you may want to give the windows different names - at the moment they are both called "popUp1", so if the first window is open when the second function is called or vice versa, the window will get reused & the different sizes you want will get ignored.

If it's still not working, can you post your entire code please?

Cheers,

Chris

Reply With Quote
  #16 (permalink)  
Old September 28th, 2004, 04:54 AM
Authorized User
 
Join Date: Feb 2004
Location: , , .
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is the story.
I have a file that contains fields. Next to each field, I have a link (referes to help.jsp) that once is clicked popups a window with the field definition.
Due to the fact that some messages are longer than others, I need different popup windows. For this reason, I have a another link that referes to help1.jsp

Because I use those files quite often, I add them as "include files".
The same thing happens with the popup windows javascript functions. I know I should use a proper javascript library but for the moment I am using a "include of javascriptLib.html". javascripLib.html contains javascript scripts.

Here it goes:

file.jsp that contains the fields and the links to help.

<form action="add_service.jsp" method=post>
<table>
  <tbody>
  <tr>
    <td>Service label:</td>
    <td><input type=text tabindex=1 name="serv_lab"></td>
<%
    String msg="\'"+(String)id.getHelp("service_label")+"\'";
   <tr>
    <td>Conexions:</td>
    <td><input type=text tabindex=1 name="conn"></td>
<%
     msg="\'"+(String)id.getHelp("conn")+"\'";
%>
  <%@ include file="../includes/help1.jsp"%>
  <%@ include file="../includes/help.jsp"%>

help.jsp contains:
<td><a href="javascript:explain(<%=msg%>);" onMouseOver="window.status='Expl...';return true;" onMouseOut="window.status='';return true;"><img src=".
./img/question.gif" ></a> </td>

help1.jsp contains
<td><a href="javascript:explain1(<%=msg%>);" onMouseOver="window.status='Expl...';return true;" onMouseOut="window.status='';return true;"><img src=".
./img/question.gif" ></a> </td>

javascriptLib.html contains
<script language="JavaScript">
javascript:window.history.forward(1);
var newwin;
var newwin1;

......function explain(msg)
{
newwin = window.open('', 'popUp',"top=150,left=150,height=110,width=325,loc ation
=no,scrollbars=no,menubars=no,toolbars=no,resizabl e=no, menubar=no");
newwin.focus();
setTimeout('newwin.close()', 10000);
if (!newwin.opener) newwin.opener = self;
with (newwin.document)
{
open();
write('<html>');
write('<body onLoad="document.form.box.focus()"><form name=form>' + msg + '<br>'
);
write('<p><center><input type=button value="Cerrar ventana" onClick=window.close
()>');
write('</center></form></body></html>');
close();
}
} function explain1(msg)
{
newwin1 = window.open('', 'popUp1',"top=150,left=150,height=180,width=325,lo cati
on=no,scrollbars=no,menubars=no,toolbars=no,resiza ble=no, menubar=no");
setTimeout('newwin1.close()', 60000);
newwin1.focus();
if (!newwin1.opener) newwin1.opener = self;
with (newwin1.document)
{
open();
write('<html>');
write('<body onLoad="document.form.box.focus()"><form name=form>' + msg + '<br>'
);
write('<p><center><input type=button value="Cerrar ventana" onClick=window.close
()>');
write('</center></form></body></html>');
close();
}
}

Hope that helps.










Reply With Quote
  #17 (permalink)  
Old September 28th, 2004, 11:03 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Elisabeth,

I expanded your code to get
Code:
<html>

<head>
<title></title>
</head>

<body>

<form action="add_service.jsp" method=post>
<table>
  <tbody>
  <tr>
    <td>Service label:</td>
    <td><input type=text tabindex=1 name="serv_lab"></td>
   <tr>
    <td>Conexions:</td>
    <td><input type=text tabindex=1 name="conn"></td>

<td><a href="javascript:explain('some message');" onMouseOver="window.status='Expl...';return true;" onMouseOut="window.status='';return true;"><img src=".
./img/question.gif" ></a>    </td>

<td><a href="javascript:explain1('some other message');" onMouseOver="window.status='Expl...';return true;" onMouseOut="window.status='';return true;"><img src=".
./img/question.gif" ></a>    </td>

<script language="JavaScript">
javascript:window.history.forward(1);
var newwin;
var newwin1;

function explain(msg)
{
    newwin = window.open('', 'popUp',"top=150,left=150,height=110,width=325,location=no,scrollbars=no,menubars=no,toolbars=no,resizable=no, menubar=no");
    newwin.focus();
    setTimeout('newwin.close()', 10000);
    if (!newwin.opener) newwin.opener = self;
    with (newwin.document)
    {
        open();
        write('<html>');
        write('<body onLoad="document.form.box.focus()"><form name=form>' + msg + '<br>');
        write('<p><center><input type=button value="Cerrar ventana" onClick=window.close()>');
        write('</center></form></body></html>');
        close();
    }
}            

function explain1(msg)
{
    newwin1 = window.open('', 'popUp1',"top=150,left=150,height=180,width=325,location=no,scrollbars=no,menubars=no,toolbars=no,resizable=no, menubar=no");
    setTimeout('newwin1.close()', 10000);
    newwin1.focus();
    if (!newwin1.opener) newwin1.opener = self;
    with (newwin1.document)
    {
        open();
        write('<html>');
        write('<body onLoad="document.form.box.focus()"><form name=form>' + msg + '<br>');
        write('<p><center><input type=button value="Cerrar ventana" onClick=window.close()>');
        write('</center></form></body></html>');
        close();
    }
}
</script>   


</body>

</html>
And both windows close fine. You get an error in each caused by "document.form.box.focus()", but that's because theres no "box" element in your form.

Best regards,

Chris

Reply With Quote
  #18 (permalink)  
Old September 28th, 2004, 12:03 PM
Authorized User
 
Join Date: Feb 2004
Location: , , .
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK, I will see what is wrong then when I use includes.
Thanks for your help. I will try it out tomorrow and will come back to you.

Reply With Quote
  #19 (permalink)  
Old January 29th, 2017, 01:34 AM
Friend of Wrox
Points: 528, Level: 8
Points: 528, Level: 8 Points: 528, Level: 8 Points: 528, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2014
Posts: 136
Thanks: 1
Thanked 10 Times in 10 Posts
Default

Ok.. this is not for the forum this post and I am sorry... I tried creating a new thread with no success (not sure why, guess I am not a paying member if their is such a thing...didn't thing there was). I have come to this site and actually started my "coding forum" experience on this site. I have bought several books and have found them extremely valuable...could almost be deemed a necessity in the academia. However THIS SITE HAS GOT OLD VERRRRRY OLD AND TIRED and it shows almost no one posts,or at least my screen shows it, and this site has the look and feel of a 1990's application . Lets update the look and feel, the technology behind it, and possibly write a book on it. ALSO FIX THE LOGIN BUGS. surely I am not the only one to have experienced them.


I apologize if I am being brash but I like this site and the wrox books, and it needs to change with the times.
Reply With Quote
  #20 (permalink)  
Old January 29th, 2017, 01:43 AM
Friend of Wrox
Points: 528, Level: 8
Points: 528, Level: 8 Points: 528, Level: 8 Points: 528, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2014
Posts: 136
Thanks: 1
Thanked 10 Times in 10 Posts
Default

Ok.. this is not for this forum/post and I am sorry... I tried creating a new thread with no success (not sure why, guess I am not a paying member if their is such a thing..didn't think there was). I have come to this site and actually started my "coding forum" experience on this site. I have bought several books and have found them extremely valuable...could almost be deemed a necessity in the academia. However, THIS SITE HAS GOTTEN OLD AND VERRRRRY TIRED; and it shows, almost no one posts or at least my screen shows it...this site has the look and feel of a 1990's application. Lets update it...maybe using the technology described most here in/. Possibly write a book on it. ALSO FIX THE LOGIN BUGS. surely I am not the only one to have experienced them.

JUST don't update it with a 10 year old look/feel as well as 20 year old backend like my company did.

I apologize if I am being brash but I like this site and the wrox books, and it needs to change with the times.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Restoring minimized window gbianchi Pro VB 6 2 July 11th, 2005 02:23 PM
alerting popup windown in minimized form sirsyme Javascript How-To 4 February 4th, 2005 05:04 AM
how to blink the minimized window vickyj Classic ASP Basics 0 January 25th, 2005 06:18 AM
showing a popup window on click widad Classic ASP Basics 4 October 15th, 2004 09:50 AM
New created popup window automatically minimized! elisabeth Javascript How-To 1 September 21st, 2004 07:20 AM



All times are GMT -4. The time now is 05:58 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.