472,972 Members | 2,271 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

open new window problem

Hi there,

I have a problem with opening new windows with JS. If the webpage did not
complete loading due to any reason a click on a link which is supposed to open a
small new other window loads instead the home page. If the page completes
loading the link is working perfect.

Here is the code:
<a href="#"
onclick="open_center('/subapp_profiles/member-information.php?id=00000028',475,500);return
false;" onMouseOver="status='display profile'; return true;"
onMouseOut="status='';" title="display profile">link text</a>

Does anybody know how to fix that?

Thanx in advance,

Merlin
Jul 23 '05 #1
7 1736
Lee
Merlin said:

Hi there,

I have a problem with opening new windows with JS. If the webpage did not
complete loading due to any reason a click on a link which is supposed to open a
small new other window loads instead the home page. If the page completes
loading the link is working perfect.

Here is the code:
<a href="#"
onclick="open_center('/subapp_profiles/member-information.php?id=00000028',475,500);return
false;" onMouseOver="status='display profile'; return true;"
onMouseOut="status='';" title="display profile">link text</a>

Does anybody know how to fix that?


Define open_center() in the <head> section of your page, so it will
exist before the link is available to be clicked.

Jul 23 '05 #2


Lee wrote:
Merlin said:
Hi there,

I have a problem with opening new windows with JS. If the webpage did not
complete loading due to any reason a click on a link which is supposed to open a
small new other window loads instead the home page. If the page completes
loading the link is working perfect.

Here is the code:
<a href="#"
onclick="open_center('/subapp_profiles/member-information.php?id=00000028',475,500);return
false;" onMouseOver="status='display profile'; return true;"
onMouseOut="status='';" title="display profile">link text</a>

Does anybody know how to fix that?

Define open_center() in the <head> section of your page, so it will
exist before the link is available to be clicked.


the open_center() funciton is inside a .js file which is loaded in the header
section of the page. So this should not be the problem. I guess it has to do
something with the way the link is coded. Any other ideas?

Thanx for any hint,

Merlin
Jul 23 '05 #3
Lee
Merlin said:

Lee wrote:
Merlin said:
Hi there,

I have a problem with opening new windows with JS. If the webpage did not
complete loading due to any reason a click on a link which is supposed to open a
small new other window loads instead the home page. If the page completes
loading the link is working perfect.

Here is the code:
<a href="#"
onclick="open_center('/subapp_profiles/member-information.php?id=00000028',475,500);return
false;" onMouseOver="status='display profile'; return true;"
onMouseOut="status='';" title="display profile">link text</a>

Does anybody know how to fix that?

Define open_center() in the <head> section of your page, so it will
exist before the link is available to be clicked.


the open_center() funciton is inside a .js file which is loaded in the header
section of the page. So this should not be the problem.


Not true. You can't be sure that a .js file is completely loaded
when the body starts to load.

Jul 23 '05 #4
Merlin <ne*********@gmx.de> wrote in message news:<2n************@uni-berlin.de>...
<a href="#"
onclick="open_center('/subapp_profiles/member-information.php?id=00000028',475,500);return
false;"
Calls a function. What does the function do? Not documented.
onMouseOver="status='display profile'; return true;"
Sets a switch
onMouseOut="status='';"

Resets a switch

title="display profile">link text</a>
I do not believe that you have provided enough information.

Could you provide a website?

Could you provide more code?

Could you write up a minimal web page with all the code and conrols
and duplicate the problem?

Robert
Jul 23 '05 #5


Robert wrote:
Merlin <ne*********@gmx.de> wrote in message news:<2n************@uni-berlin.de>...

<a href="#"
onclick="open_center('/subapp_profiles/member-information.php?id=00000028',475,500);return
false;"

Calls a function. What does the function do? Not documented.
onMouseOver="status='display profile'; return true;"
Sets a switch

onMouseOut="status='';"


Resets a switch

title="display profile">link text</a>
I do not believe that you have provided enough information.

Could you provide a website?

Could you provide more code?

Could you write up a minimal web page with all the code and conrols
and duplicate the problem?

Robert


I did copy the code from the .js file into the header, but the same result.
If the page did not finish loading due to some images or similar a click on the
link takes the user to the home page instead of opening a new window.

Here is the code for open_center();
// opens a new window in the middle of the screen without buttons and bars
//-------------------------------------------------------------------------------------------------------
function open_center(url,width_,height_,scrollbar,toolbar,m enubar,jump) {

var H_Browserrand = 12;
var V_Browserrand = 30;
var H_Aufloesung = screen.availWidth;
var V_Aufloesung = screen.availHeight;
var H_Fenstergr = H_Aufloesung-H_Browserrand;
var V_Fenstergr = V_Aufloesung-V_Browserrand;

Fensterbreite = width_;
Fensterhoehe = height_;

H_offset= (H_Fenstergr-Fensterbreite)/2;
V_offset= (V_Fenstergr-Fensterhoehe)/2;

if (V_Fenstergr < Fensterhoehe){ // maybe the client has a smaller resulution
than the image?
V_offset = 0;
Fensterhoehe = V_Fenstergr;
vlimit= V_Fenstergr;
}
else{
vlimit = 0;
}

// if (popup) popup.close();
var popup =
window.open(url+'&vlimit='+vlimit+'#'+jump,'Detail ','width='+Fensterbreite+',height='+Fensterhoehe+' ,left='+H_offset+',top='+V_offset+',
resizable=no,scrollbars='+scrollbar+',toolbar='+to olbar+',status=no,directories=no,menubar='+menubar +',location=no')
popup.focus();
return popup;
};
//-------------------------------------------------------------------------------------------------------

The page in action can be viewed here (click on a picture to see the problem):
http://www.globosapiens.net/travel-i...Nice-1172.html

Thank you for any help,

Merlin
Jul 23 '05 #6
Merlin <ne*********@gmx.de> wrote in message news:<2n************@uni-berlin.de>...
Robert wrote:
Merlin <ne*********@gmx.de> wrote in message news:<2n************@uni-berlin.de>...
Here is the code for open_center();
// opens a new window in the middle of the screen without buttons and bars
//-------------------------------------------------------------------------------------------------------
function open_center(url,width_,height_,scrollbar,toolbar,m enubar,jump) {
The function has seven parameters but you only pass it three. Here is
a version of open_center that fills in the missing parameters.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>Invoke a popup</title>
<script type="text/javascript">

function open_center(url,width_,height_,scrollbar,toolbar,m enubar,jump)
{
if( typeof scrollbar == "undefined" )
{ scrollbar = "yes";}

if( typeof toolbar == "undefined" )
{ toolbar = "yes";}

if( typeof menubar == "undefined" )
{ menubar = "yes";}

if( typeof jump == "undefined" )
{ jump = " ";}

alert("scrollbar = " + scrollbar +
" toolbar = " + toolbar +
" menubar = " + menubar +
" jump = " + jump );
var H_Browserrand = 12;
var V_Browserrand = 30;
var H_Aufloesung = screen.availWidth;
var V_Aufloesung = screen.availHeight;
var H_Fenstergr = H_Aufloesung-H_Browserrand;
var V_Fenstergr = V_Aufloesung-V_Browserrand;

// You are settting glabal variables here.
Fensterbreite = width_;
Fensterhoehe = height_;

H_offset= (H_Fenstergr-Fensterbreite)/2;
V_offset= (V_Fenstergr-Fensterhoehe)/2;

// maybe the client has a smaller resulution than the image?
if (V_Fenstergr < Fensterhoehe){
V_offset = 0;
Fensterhoehe = V_Fenstergr;
vlimit= V_Fenstergr;
}
else{
vlimit = 0;
}

var popup =
window.open(url+'&vlimit='+vlimit+'#'+jump,'Detail ',
'width='+Fensterbreite+
',height='+Fensterhoehe+
',left='+H_offset+
',top='+V_offset+
', resizable=no,scrollbars='+scrollbar+
',toolbar='+toolbar+
',status=no,directories=no,menubar='+menubar+',loc ation=no')

popup.focus();
return popup;
};

</script>

<BODY>
<p>Let's see if we can pop something up...

<a href="#"
onclick=
"open_center('http://www.yahoo.com?',
475,
500); return false;"
onMouseOver="status='display profile'; return true;"
onMouseOut="status='';" title="display profile">click here</a>

</body>
</html>

You are setting two global variables. Did you want too? See my
comment in the code.
The page in action can be viewed here (click on a picture to see the problem):
http://www.globosapiens.net/travel-i...Nice-1172.html

This is a nice and informative site. It is professionally done with a
lot of thought put into it. You are best advised to contact the
programming team who wrote the site and inquire why you are
experiencing difficulties with the page.

Robert
Jul 23 '05 #7
Lee wrote:
the open_center() funciton is inside a .js file which is loaded in the header
section of the page. So this should not be the problem.


Not true. You can't be sure that a .js file is completely loaded
when the body starts to load.


I would certainly hope you can be sure a .js file is completely loaded when the body starts to load. The only exception to this is to
explicitly use the DEFER attribute on the <SCRIPT> tag, which does allow the browser to parse/execute the JavaScript anytime it likes.

<url: http://www.w3.org/TR/html4/interact/....html#h-18.2.1 />

defer [CI]
When set, this boolean attribute provides a hint to the user agent that the script is not going to generate any document content (e.g.,
no "document.write" in javascript) and thus, the user agent can continue parsing and rendering.

Given that DEFER explicitly allows the user agent to continue parsing and rendering (the HTML), it follows that the default (non-DEFER)
alternative is that the browser stops to parse/execute the JavaScript before continuing to parse the HTML.

If you have an example of a user agent that does not load:

<script type="text/javascript" src="one.js"></script>
<script type="text/javascript" src="two.js"></script>
<script type="text/javascript" src="three.js"></script>

reproducibly sequentially, I'd be interested in knowing which one it is. I'd also recommend you contact the vendor and suggest they
correct this behavior.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq

Jul 23 '05 #8

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

Similar topics

18
by: Paul | last post by:
I link to a web site from an Excel spreadsheet. The page i link to is getCookie.asp which sets a cookie then returns back some html which opens a new window, to the same site but a different page...
2
by: venkatesh | last post by:
Hi Members, I have used the below mentioned code to open a html page in a new browser. The window size is 200 x 300. In that browser, I've given code to open another browser of the same size....
4
by: Phillip Parr | last post by:
Hello, I have a nice system where someone clicks on a picture to show the full version. This pops up in a window.open box. It works great, the only problem is that if the user clicks a second...
4
by: Anna Quick | last post by:
I am quite new to javascript, and don't seem to find the problem with stupid internet explorer. The script works fine in safari and mozilla. I searched the groups, but evidently put in the wrong...
10
by: David McCulloch | last post by:
The following code opens a new window, but the "resizeTo" doesn't resize it. Why not? (Don't ask why I simply did not open the window with the new size....my original problem was how to open a...
2
by: Samir Pandey | last post by:
Hello, I am using the following javascript code to open a new window. Somehow, IE always opens a new window. It doesn't open target url in the window name given. All i want is, if there is a...
2
by: carlor | last post by:
Hi there, I have a form that contains a link button. When the user clicks the link button I need to enable a couple of other buttons on the page and open a new browser window giving it focus...
13
by: Seth Grimes | last post by:
Hello all, I want to open a window when a user leaves my site. I set up a function called by onUnload. To skip the window.open if the user hasn't left my site, I set a variable in my links and...
18
by: len.hartley | last post by:
Hi, I am trying to pop-up a window when the user clicks on an image. The problem is that when the user clicks on the image and the window pops up OK, but the window underneath also proceeds to...
7
by: anthony.turcotte | last post by:
Hi, I've looked for a solution to this problem on google, read posts in this newsgroup and I still haven't found anything that could help me. Here's the scenario. 1. User accesses...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.