Forum Moderators: open

Message Too Old, No Replies

Pop up windows

         

Magpie

3:40 pm on Feb 13, 2005 (gmt 0)

10+ Year Member



Hey there...
I have a series of pictures on my wesite, when you click on them it opens up a new page with a full size picture on it...
Instead of doing this I would like it that when you click on the smaller picture it opens up the bigger picture in a window fit for the picture. No address bar, back button etc... i was thinking the size being H480 and W630

here is my code at the moment... Could someone possible alter it to what it should say:

--------------------------------------------------------------

</script>

<title>Under Judgement Gig: 21st November 2003</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<meta name="Microsoft Theme" content="under-judgement 1100, default">
</head>

<body>

<p align="center"><br>
<img border="0" src="images/Gig%20Pics/21.11.03/Gig%20PicS%20001.jpg" width="52" height="80"></a>
<img border="0" src="images/Gig%20Pics/21.11.03/Gig%20PicS%20002.jpg" width="52" height="80">
<img border="0" src="images/Gig%20Pics/21.11.03/Gig%20PicS%20003.jpg" width="52" height="80">
<img border="0" src="images/Gig%20Pics/21.11.03/Gig%20PicS%20004.jpg" width="52" height="80">
<img border="0" src="images/Gig%20Pics/21.11.03/Gig%20PicS%20005.jpg" width="52" height="80">
<img border="0" src="images/Gig%20Pics/21.11.03/Gig%20PicS%20006.jpg" width="52" height="80">
<img border="0" src="images/Gig%20Pics/21.11.03/Gig%20PicS%20007.jpg" width="52" height="80">
<img border="0" src="images/Gig%20Pics/21.11.03/Gig%20PicS%20008.jpg" width="52" height="80"></p><p align="center">
<img border="0" src="images/Gig%20Pics/21.11.03/Gig%20PicS%20009.jpg" width="52" height="80">
<img border="0" src="images/Gig%20Pics/21.11.03/Gig%20PicS%20010.jpg" width="52" height="80">
<img border="0" src="images/Gig%20Pics/21.11.03/Gig%20PicS%20011.jpg" width="52" height="80">
<img border="0" src="images/Gig%20Pics/21.11.03/Gig%20PicS%20012.jpg" width="52" height="80">
<img border="0" src="images/Gig%20Pics/21.11.03/Gig%20PicS%20013.jpg" width="52" height="80">
<img border="0" src="images/Gig%20Pics/21.11.03/Gig%20PicS%20014.jpg" width="52" height="80">
<img border="0" src="images/Gig%20Pics/21.11.03/Gig%20PicS%20015.jpg" width="52" height="80">
<img border="0" src="images/Gig%20Pics/21.11.03/Gig%20PicS%20016.jpg" width="52" height="80"></p><p align="center">
<img border="0" src="images/Gig%20Pics/21.11.03/Gig%20PicS%20017.jpg" width="52" height="80">
<img border="0" src="images/Gig%20Pics/21.11.03/Gig%20PicS%20018.jpg" width="52" height="80">
<img border="0" src="images/Gig%20Pics/21.11.03/Gig%20PicS%20019.jpg" width="52" height="80">
<img border="0" src="images/Gig%20Pics/21.11.03/Gig%20PicS%20020.jpg" width="52" height="80">
<img border="0" src="images/Gig%20Pics/21.11.03/Gig%20PicS%20021.jpg" width="52" height="80">
<img border="0" src="images/Gig%20Pics/21.11.03/Gig%20PicS%20022.jpg" width="52" height="80">
<img border="0" src="images/Gig%20Pics/21.11.03/Gig%20PicS%20023.jpg" width="52" height="80">
<img border="0" src="images/Gig%20Pics/21.11.03/Gig%20PicS%20024.jpg" width="52" height="80"></p>

</body>
</html>

-------------------------------------------------------------------------

All help is much appreciated

Regards
Magpie

tedster

4:11 pm on Feb 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Check out message #4 on the generic javascript thread [webmasterworld.com] titled "CUSTOM SIZE POPUP WINDOWS". It should be what you need.

Magpie

4:44 pm on Feb 13, 2005 (gmt 0)

10+ Year Member



As I am no good with this sort of stuff, it doesnt really make sense to me... I dont know what I need to write or where

Could you help with that... or anyone

Much appreciated

Magpie

tedster

6:53 pm on Feb 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'll try to fill in some missing detail. As the reference thread states, the first bit goes into the <head> section of your html document - it should be the content of a <script> element:

<script type="text/javascript">
[paste in here]
</script>

Then your thumbnail images each need to be made into a link, so that a click opens the new window.

You can just replace "page.html" with the file name for the enlarged image, and replace "Click for popup window" with the file name of your thumbnail sized image.

Magpie

7:58 pm on Feb 13, 2005 (gmt 0)

10+ Year Member



This is gonna sound lame... But I'm still struggling to understand...

lol

If you could change my code to what I need i would be very greatful

Cheers

Magpie

tedster

8:48 pm on Feb 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How can I say this -- I want to teach people to fish here, and not just give them a fish. The struggle to understand is a very healthy (and unavoidable) thing.

So focus in on what is still confusing to you, and ask a specific question. I'll be glad to help at that level. And then you will have a new tool in your toolkit. Opening a pop-up window is a function that you will probably want to use in the future, even if you are just doing the website as a sideline.

One extra bit of information might help - I told you, above, to load the large IMAGE in the pop-up window. But you can often get better results by first creating a PAGE - one that only has the image as its content. Then use the function to load that new page.

You'll be making a different .html file for each large image, and then pluggin that file name into the <body> mark-up in the spot where "page.html" appears.

One extra comment - the html you pasted in above has no ancho tags -- no links. So jus that much will not open any new page, in the same window or a new window. You need to wrap each image in an anchor tag. In a simple case, it just opens a new page in the same window. But if you use the javascript link, it will open the new page in a NEW window.

Magpie

6:12 pm on Feb 16, 2005 (gmt 0)

10+ Year Member



Right.... basically I have a bit of code on my website that when I want to advertise one of my bands gigs on the main page, a pop up loads up with a picture of the flyer advertising the gig... I use this following code on my main page to call the pop up:

<script language="JavaScript" for="window" event="onload()">
<!--
window.open
("sggig.htm","vb","height=480,width=630")
//-->
</script>

-------------------------------------------------------------------------

That is basically calling a page that i have created with the picture in it..... The page that I am calling has this code in it to get rid of the margins, address bar and buttons etc and makes it fit for the picture:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Verge Show</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />

<style type="text/css">
/*<![CDATA[*/
body
{
margin:0;
padding:0;
}
/*//]]/*/
</style>

<title>Verge Show</title>

</head>
<body>
<div>
<img src="../../images/Gig%20Pics%20/21.11.03/Gig%20Pic%20001.jpg" alt="Under Judgement" border="0" width="630" height="480"/>
</div>
</body>
<html/>

-----------------------------------------------------------------

What I really want to do is this:

Instead of it being a pop up.... When u go to one of my pages that has a series of small pictures in it.... i want it so that when u click on on of the small pictures it does sort of the same thing.... I would like it to bring up a new window without all the buttons, margins and address bar etc. and to the fit size of the picture.... so that the user cant maximise it at all....

Can any thing be done with the code i have so far?

All help is much appreciated!

Regards
Magpie

Magpie

10:41 pm on Feb 16, 2005 (gmt 0)

10+ Year Member



Would this be possible?

tedster

11:56 pm on Feb 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can't do it with the EXACT script you currently have, but it's easy enough to do using the same window.open() method.

Here's the general syntax of the javascript window.open() method. There are three parameters than can be accepted within the parenthesis.

window.open (URL,windowname,features)

1. The parameter "URL" is URL of the page to load in the new window.

2. The parameter "windowname" is the name you can given to the new window. You can use that name to refer this window again, or you can choose not to assign any name at all to the window.

3. The "features" string determines what window features will be in the popup window (such as the status bar, the address bar, resizability, etc) Once you declare any feature, then all the other features default to "no" (which is the same as "0") unless you explicitly declare them as "yes" ("1")

So, the following code opens a new window named "mywindow" that has a status bar but no other features.

window.open("http://www.example.com/page.html","mywindow","status=1");

If you put that basic information together with the particulars on the generic javascript thread [webmasterworld.com], Message #4 you will have all the ingredients to make your new windows do whatever you want.

Magpie

12:42 am on Feb 17, 2005 (gmt 0)

10+ Year Member



Hey Tedster...

I really apreciate all your help... Im just trying to understand wht it all means... After carefully reading everything you have written, althought they are amazing explanations... I can't seem to action it and make it work on my website... I dont really know what to write or where to put things.... everything I have done on my site so far has pretty much been done by you guys here at webmasterworld.... every thing from Iframes and loads of technical things.... but this problem (which sounds alot easier than the problems ive had previously and solved with help) has really stummped me... I can honestly say tho that after this i cant think of any thing more to do to my site that would make it look any better

Sorry for being a right pain...

Again I really appreciate it..

Magpie

tedster

12:58 am on Feb 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is a javascript thing - and javascript is not at ALL forgiving, the way HTML can be. It's a rigorous scripting language and we simply must follow its rules perfectly.

Knowing that, just experiment with it - this is essentially a basic javascript exercise, but know that it will not forgive missing quotes, or wrong case letters, or line breaks in the middle of a line of script...and so on.

If you can't get it to work after an honest effort (I'd be surpised, by the way) I'm sure the folks in the Javascript forum will help you find the problem.

Ultimately, it's head-banging simple, even mindlessly simple. Just a pure machine thing with no wiggle room for human-style errors. So be like a machine.

Magpie

1:10 am on Feb 17, 2005 (gmt 0)

10+ Year Member



Could you possibly give me one example of a link? becasue at the moment all i have is this... The reason i come here is becasue I dont understand it all to well.... some of the languse u guys use confuses me and i lose track.

<a href="javascript:window.open("http://www.example.com/page.html","mywindow","status=1");

Magpie

3:09 am on Feb 17, 2005 (gmt 0)

10+ Year Member



Ok I've done it.... Just by doin wht you said... I played around with it and learnt about it...

on my page with all the small pictures on it i have:

<script language="JavaScript">
function cPop(url, wide, high)
{window.open(url,"popup",'width=' + wide + ',height=' + high);
}
</script>

and in the link of the picture I have:

<a href="javascript:cPop('urlofpage.htm',630,480)">

---------------------------------------------------------------

and to get rid of all of the margins and address bar etc I just used the same code as I showd before on the page that holds the bigger picture:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Verge Show</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />

<style type="text/css">
/*<![CDATA[*/
body
{
margin:0;
padding:0;
}
/*//]]/*/
</style>

<title>Verge Show</title>

</head>
<body>
<div>
<img src="../../images/Gig%20Pics%20/21.11.03/Gig%20Pic%20001.jpg" alt="Under Judgement" border="0" width="630" height="480"/>
</div>
</body>
<html/>

Again... cheers for all the help mate.... really appreciate it

Magpie

tedster

3:15 am on Feb 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A full link, on an image, might look like this:

<a href="javascript:window.open("bigimage.html","mywindow","status=1,width=300,height=500")"><img src="littleimage.jpg" width="20" height="20" alt=""></a>

I find it too easy to lose track when there are a lot of links on a page and they all have such involved javascript in them - that's why I prefer to approach this kind of thing by first defining a function in the head section that takes care of all the basics that every link will need.

Then in the body section, the links just need to call the function that I defined, and pass the parameters to it that change with every link.

So, on the Generic Javascript page, I advise defining a function that I named cPop (my shorthand for custom pop-up) an placing it in the <head> section of the page.

<script type="text/javascript">
function cPop(url, wide, high)
{window.open(url,"popup",'width=' + wide + ',height=' + high);
}
</script>

My cPop function takes three parameters: the URL, wide, and high. In this particular function, I chose to name each window the same thing - "popup" - because I didn't expect to need separate windows for each image. If the user leaves the window open, then any other image will just load in the same window and that's OK by me.

The specific combination of single and double quotes is important to get right, by the way.

Then in the body, when I need a pop-up link, I can use the function that I already defined once in the head section, ad pass it the three exact parameters that I need in each specific case. And that way, I have a short and tidy looking link:

<a href="javascript:cPop('page.html',300,500)"><img src="smallimage.jpg" width="20" height="20" alt=""></a>

Because I already used double quotes preceding the word javascript, I use single quotes around the url.

Notice each part used in the mark-up for the link:

a -
the opening anchor tag

href -
the anchor tag's attribute, that tells you what the link will do

javascript: -
when the link is clicked, a javascript function will be called

cPop -
the name of the specific function I created in the head section

('page.html',300,500) -
the three parameters that the cPop() function needs to do its work

<img src="smallimage.jpg"> -
The thumbnail image that becomes hot-linked

</a> -
The closing anchor tag

By the way, when technical terms are unfamiliar for me, I use Google. Every one of us has areas of technology that we just don't know - that's the situation. So if I don't understand, I look it up. And that happens almost every day.

Things can get a bit confusing because not every person uses technical vocabulary in an exact way - that would be nice, but it's not reality on a forum. Nevertheless, search engines will help you find your way through many unknown technical areas. And then, after a while, you find you've learned enough to get around on you own.

Magpie

8:01 am on Feb 17, 2005 (gmt 0)

10+ Year Member



Ah i see now.... That has made it alot easier... Cheers for that tedster... you've been a great help!

Kind regards
Magpie

Magpie

10:55 am on Feb 19, 2005 (gmt 0)

10+ Year Member



Was just wondering...

When the popup loads up... how do you make it so that the new window loads up in the top left of the screen?

<script language="JavaScript">
function cPop(url, wide, high)
{window.open(url,"popup",'width=' + wide + ',height=' + high);
}
</script>

would it just be an addition to this code?

All help is much appreciated

Regards
Magpie

tedster

6:55 pm on Feb 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, that's another possible parameter in the "features string". Unfortunately there are two different versions (thanks the to past 'browser wars') but it's still pretty simple.

Let's say you want the new window to appear at these screen coordinates: [30,40]

Then you would add 4 items to the cPop() function's features string:

<script language="JavaScript">
function cPop(url, wide, high)
{window.open(url,"popup",'width=' + wide + ',height=' + high,left=30,top=40,screenX=30,screenY=40);
}
</script>

Also note, users can easily and accidentally hide the pop-up window under other open windows. Then if they click on a new enlargement, it will still load in the existing window but the user can't see it, because it's buried under other windows. For this reason, on every enlargement html page it's a good idea to use some javascript in the <body> tag that will put the pop-up window back on top every time a new page is loaded into it:

<body onLoad="window.focus()>

If you do a web search on a phrase like [window open features string] you will find many more possible additions - not all of which enjoy univeral browser support, but some of which do. Just be aware that the features string parameters should not have any spaces around the commas that separate them from each other - neither preceding or following.

Magpie

2:48 pm on Feb 23, 2005 (gmt 0)

10+ Year Member



Hey tedster!

I've put in this code as you said:

<script language="JavaScript">
function cPop(url, wide, high)
{window.open(url,"popup",'width=' + wide + ',height=' + high,left=30,top=40,screenX=30,screenY=40);
}
</script>

when I go to click on one of the pictures it does not work.... Internet Explorer gives me this error message:

Line: 44
Char: 2
Error: Not Implemented
Code: 0
Url: [......]

tedster

6:41 pm on Feb 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmmmm.... there is no line 44 in that particular javascript. Makes me think that you have some other script referenced somewhere on the page that is causing the error.

If you test in a different browser, like Firefox, you'll find the javascript console gives more helpful error information.