473,387 Members | 1,388 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

specify new window with js in IE

this is a problem i can't figure out.
I can't get IE to link to a new widown with width/height attributes as i can
in other browsers. It works in NN, Op, Moz.
The code is all on the same line as per msdn
Here's the code:
...
<a href="#" target="_self" onClick="window.open('images/prod/Ggps2.jpg','GPS
II','toolbar=no,width=200,height=200,left=50,top=5 0,status=no,scrollbars=no,
resize=no');return false"><img border="0" src="images/thumb/Ggps2.gif"
alt="GPS II" width="73" height="70"></a>.
...
any help would be appreciated
Fred

Jul 23 '05 #1
3 1810
Ivo
"Fred" wrote
I can't get IE to link to a new widown with width/height attributes as i can in other browsers. It works in NN, Op, Moz.
The code is all on the same line as per msdn
Here's the code:
..
<a href="#" target="_self" onClick="window.open('images/prod/Ggps2.jpg','GPS II','toolbar=no,width=200,height=200,left=50,top=5 0,status=no,scrollbars=no, resize=no');return false"><img border="0" src="images/thumb/Ggps2.gif"
alt="GPS II" width="73" height="70"></a>.
..
Change the target to something else perhaps? That is the value of the target
attribute of the <a> element. If you specify "GPSII" as the target, chances
are it will open in that window.
By the way, any feature not listed in that third parameter will be absent
from the new window (as per msdn). If you remove every "xxxxx=no" the code
will be easier to maintain. Features that are listed are taken as wanted
even without an explicit "=yes" and will be present in the new window.
Also, may I suggest keeping it resizeable? Because why not.
Your link tag would then look like this:

<a
href="images/prod/Ggps2.jpg"
target="_self"

onclick="window.open(this.href,this.target,'width= 200,height=200,left=50,top
=50,resizable');return false" any help would be appreciated
Fred


Welcome,
Ivo
Jul 23 '05 #2
DU
Fred wrote:
this is a problem i can't figure out.
I can't get IE to link to a new widown with width/height attributes as i can
in other browsers. It works in NN, Op, Moz.
The code is all on the same line as per msdn
Here's the code:
...
<a href="#" target="_self" onClick="window.open('images/prod/Ggps2.jpg','GPS
II','toolbar=no,width=200,height=200,left=50,top=5 0,status=no,scrollbars=no,
resize=no');return false"><img border="0" src="images/thumb/Ggps2.gif"
alt="GPS II" width="73" height="70"></a>.
...
any help would be appreciated
Fred


Ivo replied to you good answers. I'll add some more comments on top of
what he said.

The 2nd parameter of the window.open call should be one string without
any blank space otherwise MSIE 5+ will behave incorrectly. I personally
think Mozilla and Opera should NOT accept blank spaces in the target
attribute value: bugfiles should be opened on this.

You also had a contradiction between href="#" and the window.open call:
in case of javascript support disabled, clicking the link would not have
loaded that Ggps2.jpg file of yours.
You can choose to not open a new window (target="_self") in case
javascript support is disabled or you can choose to open a new window
(target="GPSII") in case javascript support is disabled: whatever you
do, your href value should be the Ggps2.jpg file at least. So that the
content is accessible despite javascript support disabled.

Finally, the code given by Ivo will not compensate for usability
problems/burdens often seen by use of window.open calls:
- bringing on top a secondary window if the opener is brought back on
top of it and if the user clicks on the link again
- recycling a secondary window so that this window (and only 1 secondary
window) can serve to show enlarged images

DU

DU
Jul 23 '05 #3
Fred wrote:
this is a problem i can't figure out.
I can't get IE to link to a new widown with width/height attributes as i can
in other browsers. It works in NN, Op, Moz.
The code is all on the same line as per msdn
Here's the code:
..
<a href="#" target="_self" onClick="window.open('images/prod/Ggps2.jpg','GPS
II','toolbar=no,width=200,height=200,left=50,top=5 0,status=no,scrollbars=no,
resize=no');return false"><img border="0" src="images/thumb/Ggps2.gif"
alt="GPS II" width="73" height="70"></a>.
..
any help would be appreciated
Fred


Everyone else missed the actual problem. The window name (2nd argument of
window.open()) can not contain spaces. Change it from "GPS II" to "GPSII" and it
should work as expected. However, a better design would be:

<a href="images/prod/Ggps2.jpg" target="GPSII"
onclick="
window.open(
this.href,
this.target,

'toolbar=no,width=200,height=200,left=50,top=50,st atus=no,scrollbars=no,resize=no'

);
return false;
"><img border="0" src="images/thumb/Ggps2.gif" alt="GPS II" width="73"
height="70"></a>

Now you get a new window with the right image regardless of whether Javascript
is enabled on the user's browser or not. Not to mention, if you do this multiple
times, you could now re-factor to move the window.open() call out of the onclick
event entirely:

<script type="text/javascript">
function openFullImage(lnk) {
window.open(
lnk.href,
lnk.target,

'toolbar=no,width=200,height=200,left=50,top=50,st atus=no,scrollbars=no,resize=no'

);
return false;
}
</script>

<a href="images/prod/Ggps1.jpg" target="GPSI"
onclick="return openFullImage(this);"><img ...></a>
<a href="images/prod/Ggps2.jpg" target="GPSII"
onclick="return openFullImage(this);"><img ...></a>
<a href="images/prod/Ggps3.jpg" target="GPSIII"
onclick="return openFullImage(this);"><img ...></a>
<!-- etc -->

The only problem with any of these designs is that an overly aggressive popup
blocker might block your full image window popups, even though they were
initiated by the user.

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 23 '05 #4

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

Similar topics

2
by: Matt | last post by:
I have a page1.asp that opens a window called page2.asp. I want page2.asp doesn't have title bar, tool bar, address bar. Is it possible to specify in javascript function window_onload() in...
1
by: kj | last post by:
I want to specify the color of certain style sheet element (say p.foo) to match the color of (unvisited) hyperlinks: p.foo { color: ??? } What should I replace ??? with to ensure that the...
4
by: deko | last post by:
I want to connect to another mdb from an existing mbd - very simple. (same local disk, same version) when I use this convention: Dim wrkJet As DAO.Workspace Dim db as DAO.Database Set...
2
by: Achraf | last post by:
Hi all, I have a c program under linux, while running, it opens a new terminal windows using a system call. I would like to display messages on both windows. But I can't find a way to specify...
1
by: MrMike | last post by:
Hi. I have an aspx page which displays data on about the top 1/3 of the page, and the remaining 2/3 of the page is blank. The page is formatted so that my users can print the page to...
16
by: JD | last post by:
Hi guys What's the best way to specify font size using CSS? I try to avoid absolute units like pt and px because then users can't resize the fonts in IE, but % and em are a complete pain to use...
1
by: Kueishiong Tu | last post by:
I have a window form application. When I port the application to another computer which has a different default font, the form gets screw up. How do I specify the font a window form use in the...
1
by: KR | last post by:
Hi, After just installing sql 2005 on our test machine, I am trying to restore a database using a backup file on the network. However, the specify backup diagol box allows only for...
0
by: jazzaddict | last post by:
Hi guys, I'm new to python and I'm learning to use python for media processing. I'm trying to come up with a loop check condition to repaint for every 1000 pixels processed so I can see the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...

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.