PDA

View Full Version : javascript new window commands


wuffy77
10-24-2007, 11:25 AM
Hi there,

I've got a div with an id of 'imgset' and it's full of lots of image thumbnails.

When you click the thumbnail it opens the full image in a new window, however is it possible to control that window with javascript?

I need the background to be black (as the default white doesn't help viewing images) and I'd also like to just have the image (not the toolbar etc that normally appears).

I've seen a few scripts doing it, but none fixing tha background color.

Also is it possible to write a script that says 'all links within the div with the id imgset' apply this script?

The ones I've seen require manual linking of every <a href> around the images - the same applies for the new window loads - I've seen lots that load a window that's the right size for the image, but again you need to specify this manually...

I'm hoping someone might be able to help out! :(

coothead
10-24-2007, 03:45 PM
Hi there wuffy77,

you can see an example here...
http://mysite.orange.co.uk/azygous/home.html
...and the code etc in the attachment.

wuffy77
10-24-2007, 05:14 PM
you know the routine Coothead - blah blah I am humbled etc! ;) ;)

However this time I'm realy stumped!

Can you tell me how your code is setting the background color?! I can see it in your <style> for the first page, but I can't see how it's transferring it to the new one!

Also strangely the resizing gizmo didn't seem to work at first, creating a tiny window (about 100px by 10px) and leaving it at that - I tested in firefox, opera and IE7 - then I went back into firefox and it was working hunky dory - IE7 & opera still appear not to work (based on your website link).

Any ideas what's causing this?

wuffy77
10-24-2007, 05:16 PM
update: Opera now sporadically works (I've just reloaded lots!) the first image works fine, then if I click the next one, it just works like a normal click link (full window, white background etc)...

It's sporadic which is strange, I can't pin down!

coothead
10-24-2007, 06:43 PM
Hi there wuffy77,

I am sorry about the problems with this one. :o :o :o

It was working OK at home.

I have added a preload and a delay to the script and it now appears to be working OK on the server.
I also went back and edited my original post with a new zip attachment.

You can check the link here....
http://mysite.orange.co.uk/azygous/home.html
...or there. ;)

I would suggest that instead of using a popup for this assignment you would be better considering displaying the images in show/hide div. :agree:

wuffy77
10-25-2007, 03:25 AM
Hi Coothead,

That's fantastic! However you still haven't answered my question about how your background image is generated (is this some master secret? ;) ).

Sorry for my ignorance but what is a show/hide div?!

I've got a page with loads of thumbsnails - like http://easyweb.easynet.co.uk/aburnham/thumbs/page1.html

I'm guessing you know some magic way to get a div to appear?! If so would it
a) appear over them, not conflict/move the other thumbs?
b) Let you do the usual right-click to save image/copy image etc?

coothead
10-25-2007, 06:41 AM
Hi there wuffy77.
However you still haven't answered my question about how your background image is generated (is this some master secret?)
This is achieved with the use of a...

query string
A query string (or search string) is an optional part of a URL that goes after the file name and begins with a question mark (?).

This line in the script...
mywindow=window.open('popupPage.html?'+pic,'',features);
...opens the pop-up and takes the image information that is after the question mark (?) where it processed by the script in popupPage.html.

Sorry for my ignorance but what is a show/hide div?!
You can see an example, which uses the same layout as for the popups, here...
http://mysite.orange.co.uk/azygous/img_gallery.html
As you will quickly notice, it is much smoother than the pop-up example.
I also think that it looks better than pop-up windows, which can vary from browser to browser. :agree:
And most importantly of all, it is not subject to pop-up blocking. :agree:

wuffy77
10-25-2007, 09:26 AM
fantastic Coothead - I didn't realise it was possible wihout popups - I'd consigned myself to running the popup-blocker gauntlet!

Absolutely perfect!

coothead
10-25-2007, 09:33 AM
Hi there wuffy77,

I am pleased that the non pop-up method meets with your approval. :agree:

I can now relax and take my daily siesta. ;)

wuffy77
10-25-2007, 09:53 AM
Heh! I dunno Coothead, I reckon you could do these things whilst you're having your siesta!

coothead
10-25-2007, 12:05 PM
Hi there wuffy77,
I reckon you could do these things whilst you're having your siesta!
Funny that you should say that. :D
Many is the time that I have found the answer to an, apparently, insoluble problem when awakening from the land of Nod. :agree: