473,699 Members | 2,933 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with window.open

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.

The webpage code is simple:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Page title</title>
<script language="JavaS cript" type="text/javascript">
var tallParm =
'scrollbars=1,t oolbar=0,locati on=0,directorie s=0,status=0,me nubar=0,resizab le=1,height='+( screen.height
- 200)+',width=' + (screen.width - 80);

function pop_tall_image_ win (ref) {
window.open(ref ,"x",tallPar m);
return false;
}
</script>
</head>
<body>
<a href="large.gif " onclick="return
pop_tall_image_ win('large.gif' )"><img src="small.gif" border="0"></a>
</body>
</html>

The place where I have the page on geocities is:
http://www.geocities.com/sample_issue/index.htm

As a side-note, I still want the link on the image to go to the target,
in case the user decides to use right-mouse open-new-window. That is
why I have the HREF reference.

Apr 26 '06 #1
18 3337
le*********@gma il.com wrote:
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.

The webpage code is simple:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Page title</title>
<script language="JavaS cript" type="text/javascript">
var tallParm =
'scrollbars=1,t oolbar=0,locati on=0,directorie s=0,status=0,me nubar=0,resizab le=1,height='+( screen.height
- 200)+',width=' + (screen.width - 80);

function pop_tall_image_ win (ref) {
window.open(ref ,"x",tallPar m);
return false;
}
</script>
</head>
<body>
<a href="large.gif " onclick="return
pop_tall_image_ win('large.gif' )"><img src="small.gif" border="0"></a>
</body>
</html>

The place where I have the page on geocities is:
http://www.geocities.com/sample_issue/index.htm

As a side-note, I still want the link on the image to go to the target,
in case the user decides to use right-mouse open-new-window. That is
why I have the HREF reference.


try
<a href="large.gif " onclick="pop_ta ll_image_win('l arge.gif'); return
false;"><img src="small.gif" border="0"></a>

- JS
http://www.endeavorpub.com

Apr 26 '06 #2
le*********@gma il.com wrote:
I am trying to pop-up a window when the user clicks on an image. <snip> <a href="large.gif " onclick="return
Assuming that this carriage return is not in the original code (and if
it is the symptoms described still would not be evident as the function
would then ver be called) this code should 'work'.
pop_tall_image_ win('large.gif' )"><img src="small.gif" ^^^^^^^^^^

Rather than pass the image file to the function as a string literal
use - this.href - as that will pass on the HREF from the A element and
save you having to update both if the image URL needs changing
(eliminating some potential for making mistakes in the process).
border="0"></a> <snip> The place where I have the page on geocities is:
http://www.geocities.com/sample_issue/index.htm

<snip>

The page at this URL does not exhibit the symptoms described (does _not_
navigate away from the page with the link) on Opera 8 or IE 6.

Richard.
Apr 26 '06 #3

jshanman wrote:
try
<a href="large.gif " onclick="pop_ta ll_image_win('l arge.gif'); return
false;"><img src="small.gif" border="0"></a>

- JS
http://www.endeavorpub.com

--> I just gave that idea a try (labelling the original "1." and this
idea "2.") and both behave the same way -- again not locally but when I
run it on geocities (public Internet?)

Apr 26 '06 #4
Richard Cornford wrote:
The page at this URL does not exhibit the symptoms described (does
_not_ navigate away from the page with the link) on Opera 8 or IE 6.

--> that's interesting that you are NOT seeing this behavior because I
get it for Firefox 1.0, IE 6.0-SP2 and Netscape 8.1 (and others have
reported it). I don't have Opera and you may have a different service
pack of IE6. It doesn't happen in IE5 (something that I forgot to
mention).

The carriage return isn't in the original code (View Source on
http://www.geocities.com/sample_issue/index.htm might be the best way
to see the code without the NewsGroup wrapping added).

Thanks for the tip on "this.href" . If I can solve this problem, it's
something that I'd like to start to use.

Apr 26 '06 #5
Any other ideas to address this?

Apr 28 '06 #6
wrote on 28 apr 2006 in comp.lang.javas cript:
Any other ideas to address this?


To addess what?

Please quote what you are replying to. If you want to post a followup via
groups.google.c om, don't use the "Reply" link at the bottom of the article.
Click on "show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
<http://www.safalra.com/special/googlegroupsrep ly/>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Apr 28 '06 #7
I am wondering if there are any other ideas to address my original
query:

-------ORIGINAL QUERY ------------------------------------------
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.

The webpage code is simple:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Page title</title>
<script language="JavaS cript" type="text/javascript">
var tallParm =
'scrollbars=1,t oolbar=0,locati on=0,directorie s=0,status=0,me nubar=0,resizab le=1,height='+( screen.height
- 200)+',width=' + (screen.width - 80);

function pop_tall_image_ win (ref) {
window.open(ref ,"x",tallPar m);
return false;
}

</script>
</head>
<body>
<a href="large.gif " onclick="return
pop_tall_image_ win('large.gif' )"><img src="small.gif" border="0"></a>
</body>
</html>

The place where I have the page on geocities is:
http://www.geocities.com/sample_issue/index.htm

As a side-note, I still want the link on the image to go to the target,
in case the user decides to use right-mouse open-new-window. That is
why I have the HREF reference.

END OF ORIGINAL QUERY ------------------------------------------

1. This was suggested and made no difference:
<a href="large.gif " onclick="pop_ta ll_image_win('l arge.gif'); return
false;"><img src="small.gif" border="0"></a>

2. Also, someone queried the line-wrapping and that is just the
newgroup posting adding carriage returns. The full code at:
http://www.geocities.com/sample_issue/index.htm has no extra carriage
returns.

3. I am seeing this in Firefox 1.0, IE 6.0-SP2 and Netscape 8.1 when
accessing the link above (and others have reported it too). Someone
suggested that it might not be happening in Opera but I don't have
Opera so I cannot comment on that.

Apr 28 '06 #8
VK

le*********@gma il.com wrote:
I am wondering if there are any other ideas to address my original
query:

-------ORIGINAL QUERY ------------------------------------------
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.

The webpage code is simple:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Page title</title>
<script language="JavaS cript" type="text/javascript">
var tallParm =
'scrollbars=1,t oolbar=0,locati on=0,directorie s=0,status=0,me nubar=0,resizab le=1,height='+( screen.height
- 200)+',width=' + (screen.width - 80);

function pop_tall_image_ win (ref) {
window.open(ref ,"x",tallPar m);
return false;
}

</script>
</head>
<body>
<a href="large.gif " onclick="return
pop_tall_image_ win('large.gif' )"><img src="small.gif" border="0"></a>
</body>
</html>

That's an old "wrapper in wrapper" bug (bug? really don't know how to
call it, seems rather a dark spot left in the specs). You have the same
with setting window.status or onsubmit handler on many UA's.

The workaround is the regular one:
....
function f() {
// do stuff
return false;
}
....
<a href="foobar.ht ml" onclick="return f();">

Apr 28 '06 #9
quote ************
len.hart...@gma il.com wrote:
I am wondering if there are any other ideas to address my original
query: -------ORIGINAL QUERY ------------------------------------------
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. The webpage code is simple: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Page title</title>
<script language="JavaS cript" type="text/javascript">
var tallParm =
'scrollbars=1,t oolbar=0,locati on=0,directorie s=0,status=0,me nubar=0,resizab le=1,height='+( screen.height
- 200)+',width=' + (screen.width - 80); function pop_tall_image_ win (ref) {
window.open(ref ,"x",tallPar m);
return false;
} </script>
</head>
<body>
<a href="large.gif " onclick="return
pop_tall_image_ win('large.gif' )"><img src="small.gif" border="0"></a>
</body>
</html>


That's an old "wrapper in wrapper" bug (bug? really don't know how to
call it, seems rather a dark spot left in the specs). You have the same
with setting window.status or onsubmit handler on many UA's.

The workaround is the regular one:
....
function f() {
// do stuff
return false;
}

....
<a href="foobar.ht ml" onclick="return f();">
end of quote **************

I don't see how what you are suggesting in in any way different from
what I have -- from onclick, call a function that always returns false
(which I do). Am I missing something here?

Apr 29 '06 #10

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

Similar topics

4
7589
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
5
10882
by: Mike | last post by:
In my previous post, I wrote: > ... > GOAL: (very simple) Provide a hyperlink which, when clicked, > calls a javascript function which opens a new URL. > ... > PROBLEM: The following code works fine if I click to open in > the same window, but if I click the browser option to open in a > new window, the new window tries to open the href URL (the > onClick function does get executed, but seems to be ignored). > ...
10
6750
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
3504
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.
5
1963
by: Richard Trahan | last post by:
I have an inscrutable problem with window.open. Consider the following code: var graphwin = window.open("","graphWin","height=400,width=400,resizable=yes"); It works perfectly in one place in my program. The window opens, I write stuff to it, close the document, and it sits there like it's supposed to. I put the identical line in a different function, which is supposed to
4
2429
by: VR | last post by:
First, greetings to everyone :) I'm doing a university seminar & I've encountered a problem. I have a gallery with thumbnails linked on pictures. What I want is popup to be opened with dimensions of linked picture after clicking on a thumbnail. I found javascript which is compatible with IE, Firefox & Opera but I can't get it to work. All I get is this http://www.justfonts.com/tini/problem.html (thumbnail dissapeared).
0
1180
by: Aryan | last post by:
Hi, I am doing "Export to Excel" functionality, but while doing this I am getting error. Like I have two types of Report, each type has many sub reports inside. So I am opening new window for Each type of report by taking help from Javascript "window.open()" and passing different type of window name. Given below example will help you to understand my problem. I have Two types of Report :- 1>Report Type A
0
1190
by: Aryan | last post by:
Hi, I am doing "Export to Excel" functionality, but while doing this I am getting error. Like I have two types of Report, each type has many sub reports inside. So I am opening new window for Each type of report by taking help from Javascript "window.open()" and passing different type of window name. Given below example will help you to understand my problem. I have Two types of Report :- 1>Report Type A
0
1227
by: Aryan | last post by:
Hi, I am doing "Export to Excel" functionality, but while doing this I am getting error. Like I have two types of Report, each type has many sub reports inside. So I am opening new window for Each type of report by taking help from Javascript "window.open()" and passing different type of window name. Given below example will help you to understand my problem. I have Two types of Report :- 1>Report Type A
0
8703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8623
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
9185
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...
0
9050
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8935
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
8893
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
7773
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
3069
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
2359
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.