473,768 Members | 5,062 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_c enter('/subapp_profiles/member-information.php ?id=00000028',4 75,500);return
false;" onMouseOver="st atus='display profile'; return true;"
onMouseOut="sta tus='';" title="display profile">link text</a>

Does anybody know how to fix that?

Thanx in advance,

Merlin
Jul 23 '05 #1
7 1783
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',4 75,500);return
false;" onMouseOver="st atus='display profile'; return true;"
onMouseOut="st atus='';" 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',4 75,500);return
false;" onMouseOver="st atus='display profile'; return true;"
onMouseOut="s tatus='';" 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="ope n_center('/subapp_profiles/member-information.php ?id=00000028',4 75,500);return
false;" onMouseOver="st atus='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*********@gm x.de> wrote in message news:<2n******* *****@uni-berlin.de>...
<a href="#"
onclick="open_c enter('/subapp_profiles/member-information.php ?id=00000028',4 75,500);return
false;"
Calls a function. What does the function do? Not documented.
onMouseOver="st atus='display profile'; return true;"
Sets a switch
onMouseOut="sta tus='';"

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*********@gm x.de> wrote in message news:<2n******* *****@uni-berlin.de>...

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

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

onMouseOut="s tatus='';"


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,tool bar,menubar,jum p) {

var H_Browserrand = 12;
var V_Browserrand = 30;
var H_Aufloesung = screen.availWid th;
var V_Aufloesung = screen.availHei ght;
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='+vli mit+'#'+jump,'D etail','width=' +Fensterbreite+ ',height='+Fens terhoehe+',left ='+H_offset+',t op='+V_offset+' ,
resizable=no,sc rollbars='+scro llbar+',toolbar ='+toolbar+',st atus=no,directo ries=no,menubar ='+menubar+',lo cation=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*********@gm x.de> wrote in message news:<2n******* *****@uni-berlin.de>...
Robert wrote:
Merlin <ne*********@gm x.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,tool bar,menubar,jum p) {
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,tool bar,menubar,jum p)
{
if( typeof scrollbar == "undefined" )
{ scrollbar = "yes";}

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

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

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

alert("scrollba r = " + scrollbar +
" toolbar = " + toolbar +
" menubar = " + menubar +
" jump = " + jump );
var H_Browserrand = 12;
var V_Browserrand = 30;
var H_Aufloesung = screen.availWid th;
var V_Aufloesung = screen.availHei ght;
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='+vli mit+'#'+jump,'D etail',
'width='+Fenste rbreite+
',height='+Fens terhoehe+
',left='+H_offs et+
',top='+V_offse t+
', resizable=no,sc rollbars='+scro llbar+
',toolbar='+too lbar+
',status=no,dir ectories=no,men ubar='+menubar+ ',location=no')

popup.focus();
return popup;
};

</script>

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

<a href="#"
onclick=
"open_center('h ttp://www.yahoo.com?' ,
475,
500); return false;"
onMouseOver="st atus='display profile'; return true;"
onMouseOut="sta tus='';" 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*****@agrico reunited.com>
comp.lang.javas cript 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
8847
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 (same folder). The cookie is not received. Can someone explain why? I worked around this by adding a cache-control header with a value of no-cache. This fixes the problem. Unfortunately that causes another problem with Internet Explorer...
2
4137
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. However, this is not happening in IE 5. Can anyone help me solve this problem? Code: Script:
4
651
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 picture before closing the first then the new picture loads into the original popup box which is often a different size. How can i make them open in their own popup windows? Thanks
4
7595
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 keywords, didn't find the solution. It seems to be as easy as it gets: open a new window with a new url. in IE (I am using IE in mac osx), the error message is: Microsoft JScript runtime error: Line: 9
10
6759
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 new window with maximized dimensions!) FYI, I uploaded the same code to: http://tosasoft.com/test/open.htm ========================================
2
3509
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 window "MyWin" already open, then the main window should load the target url in "MyWin" and not open a new window again.
2
2941
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 (keeping it on top). I have most of it working but I can't get it all working. I can either have the window open and disable the buttons with the new window in the background, or I can have the new window in the foreground but not be able to disable...
13
3249
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 test for it in the onUnload function. If the variable is set, don't open the window. If it's not -- if the user is leaving my site -- do open the window. The problem is dealing with the browser Back, Forward, and Reload buttons. I don't want...
18
3349
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 the image. The desired behavior is that when the pop-up is invoked, I want the underlying window to stay put. I don't have this problem when I run the code on my local computer but I do have it when I run the code on geocities.
7
3674
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 pageA.html 2. User clicks on menu link to open popup.html 3. pageA.html checks if popup.html is already open. It is not, open
0
9408
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10181
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9966
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9845
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8841
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7387
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6657
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3935
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3540
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.