473,382 Members | 1,180 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,382 software developers and data experts.

Replacing enlarged pics in popup works in IE only. What gives?

Seems I still haven't got the hang of all those window generating code
in Javascript. I've got a page with about 15 photo thumbnails. When you
click on a thumbnail a new window pops up which shows the enlarged
version of said thumbnail. This works fine on all current browsers I've
tested.

However, in case I do not close the popup but click on another thumbnail
instead, only IE replaces the enlarged pic by the new one, Firebird and
Opera keep the old picture. Only after closing the popup window and
clicking on the new thumbnail, the popup comes up with the new enlarged
version.

I'm quite sure this is because of some flaw in my code. Maybe you can
point me to it. Please note that I load the picture as a backround image
of the new window to make sure it takes up the whole window without any
margins, so this is already a workaround.
function enlarge(chooseImg) {
mywin =
window.open("","enlarged","width=500,height=347,le ft=20,top=20")
mywin.document.open()
mywin.document.write("<HTML><HEAD><TITLE>Enlarged view of thumbnails
</TITLE></HEAD><BODY BGCOLOR=\"#000000\" Background=\"img/" + chooseImg
+ ".jpg\"></BODY></HTML>")
mywin.focus()
}

And in the HTML my link looks like this:

<a href="javascript:enlarge('pic1_large')"><img src="img/pic1
_thumb.jpg" alt="Pic 1" width="149" height="104" border="0"></a>
Jul 20 '05 #1
2 4336
DU
Moon wrote:
Seems I still haven't got the hang of all those window generating code
in Javascript. I've got a page with about 15 photo thumbnails. When you
click on a thumbnail a new window pops up which shows the enlarged
version of said thumbnail. This works fine on all current browsers I've
tested.

Is there a particular reason why you did not provide an url for that
page? ... for checking, testing purposes?

However, in case I do not close the popup but click on another thumbnail
instead, only IE replaces the enlarged pic by the new one, Firebird and
Opera keep the old picture. Only after closing the popup window and
clicking on the new thumbnail, the popup comes up with the new enlarged
version.

I'm quite sure this is because of some flaw in my code. Maybe you can
point me to it. Please note that I load the picture as a backround image
of the new window to make sure it takes up the whole window without any
margins, so this is already a workaround.
What's wrong with a margin between an image and the browser window
frames? Margins around content (like an enlarged image) is not some kind
of nasty gap to get rid off; documents all have browser default margin
values for a reason. Such "white space" gap surrounding an image help
delineate the real size of the image (even there, the user could be
fooled by automatic image resizing feature in MSIE and Mozilla; removing
that "white space" gap from the file could make the image smaller than
its real dimensions, smaller than it should because of automatic image
resizing feature in those browsers) and the window frame. For blocks of
text, such gap is more important to help reading.


function enlarge(chooseImg) {
mywin =
window.open("","enlarged","width=500,height=347,le ft=20,top=20")
Your window object reference (mywin in your code) should be initialized
to null and then explicitly declared as a global variable. Not a mistake
but it is much more advisable. You could also use "about:blank" as the
initial document. I personally do not like creating enlarged image
window from non-existent document and then resorting to document.write
calls.
IMO, there are other better, more efficient, less cpu and RAM-demanding
and easier-to-maintain ways to achieve your goals.
Your window.open call will prevent the popup to be resizable and to have
scrollbars if needed, if content overflows requested window dimensions:
none of this is recommendable from an accessibility and usability
perspectives. Not providing reasonable fall-back mechanisms nor
providing normal, standard browser window features is bad.

mywin.document.open()
mywin.document.write("<HTML><HEAD><TITLE>Enlarged view of thumbnails
</TITLE></HEAD><BODY BGCOLOR=\"#000000\" Background=\"img/" + chooseImg
+ ".jpg\"></BODY></HTML>")
- every occurences of / should be escaped so that the HTML parser does
not get confused.
- background is an invalid HTML attribute
- there is absolutely nothing wrong with simply creating a secondary
window with the enlarged image:
WindowObjectReference = window.open("path/filename.jpg",
"EnlargedImage",
"width=500,height=347,left=20,top=20,resizable,scr ollbars,status");
alling the window.open inserting the img in an already existing file
like "about:blank" or
mywin.focus()
- You need to close the document stream here with
mywin.document.close();
"Closes a document stream opened by open() and forces rendering."
http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-98948567
- why give focus to the window which was just created a msec. ago?
- as coded your code will not reuse the already opened enlarged image
window if the user clicks on another thumbnail. You need to make major
adjustements to your code. (I see other difficulties and deficiencies
with your code.)
What might be happening in MSIE is that you're actually closing the
already opened window and then re-creating and opening a new window from
scratch.
}

And in the HTML my link looks like this:

<a href="javascript:enlarge('pic1_large')"><img src="img/pic1
_thumb.jpg" alt="Pic 1" width="149" height="104" border="0"></a>


It's widely known and documented that resorting to "javascript:"
pseudo-protocol in href attribute values is wrong, incorrect, invalid
and bound to just create problems for users. If the user has javascript
turn off, your enlarged picture won't be accessed in the opener nor in
the popup window when it should. Having "javascript:" in the href value
prevents user from choosing, say, open in a tab with their right-click
context menu or to get trustworthy, reliable info on the link
properties. Etc..
Here, you would need several code adjustements and corrections.

Among several documents:
http://jibbering.com/faq/#FAQ4_24

Finally you can compare what I preach with what I practice:

Enlarged image in a single re-usable secondary window
http://www10.brinkster.com/doctorunc...Thumbnail.html

Create a sub-window and dynamically DOM-insert an image
http://www10.brinkster.com/doctorunc...geInPopup.html

Popup windows and Netscape 7: interactive demos
http://www10.brinkster.com/doctorunc...Netscape7.html

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
http://www10.brinkster.com/doctorunc...e7Section.html

Jul 20 '05 #2
DU wrote:
Is there a particular reason why you did not provide an url for that
page? ... for checking, testing purposes?
Yep, the page wasn't up and now that it's up it's not always reachable
cause we currently have to put it on a friend's server at home.

http://magnum.homedns.org/jga.html
What's wrong with a margin between an image and the browser window
frames? Margins around content (like an enlarged image) is not some kind
of nasty gap to get rid off;
Your window.open call will prevent the popup to be resizable and to have
scrollbars if needed, if content overflows requested window dimensions:
It's wrong in such a way that I prefer having only the picture 'framed'
by the browser window and nothing else. Since the picture's always the
same size there should be no trouble and no need for scrollbars.
You need to make major adjustements to your code. (I see other
difficulties and deficiencies with your code.)
I guessed that, that's why I posted here.
What might be happening in MSIE is that you're actually closing the
already opened window and then re-creating and opening a new window from
scratch.
Seems that is what's happening, still I see no real problem with it
though it may not be very elegant. I would hate to add a more complex
function that had to verify whether a window is already open or not.
Since I want only one enlarged window open at a time I think this is an
appropriate behaviour. I'm more concerned about the other browsers NOT
showing the new picture.
Here, you would need several code adjustements and corrections.


Gonna check em out. Thanks.
Jul 20 '05 #3

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

Similar topics

2
by: Sharon | last post by:
Hi y'all, I'm trying to create a customized context menu using the DHTML Popup object. The HTML that makes up the body of the popup is created in a variable named 'popCode'. Works like a charm,...
13
by: ldan | last post by:
Hi everybody, I would not consider myself an expert in javascript - but so far whatever I know, helped me reaching my goals. Recently I started to experience a lot of javascript errors related...
1
by: Laphan | last post by:
First of all, my apologies for the xpost. I realise the netiqute, but this query seems to cross the boundaries of both these groups. Basically I have created a small ASP site that allows a user...
4
by: jm | last post by:
<asp:HyperLinkColumn runat="server" HeaderText="To" DataNavigateUrlField="calTo"...
3
by: RahimAsif | last post by:
I am writing an application that requires the a portion of the main menu to be dynamic. The menu has file, panels, view files and help across the top. The view files sub menu needs to be...
1
by: gvrajkumar | last post by:
Hi Popup window is opened and after some time session has expired. After session expire, if the user tries to make any actions on the popup page the user is redirected to login.jsp page. What...
3
by: cmo | last post by:
Well I hope I this isn't too nebulous of a problem. The problem I currently have is this: I have a button in a form that opens up a javascript/css poup that has an input field and two ahref links...
1
parshupooja
by: parshupooja | last post by:
Hello, I am using ASp.NEt C# and javascript I have a Datalist control on my page which has3 columns name , image and description. i have around 40 items in it. I want user to click on Image to...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.