Click to See Complete Forum and Search --> : I don't get it, what am I doing wrong?


Dark Dragon
09-01-2003, 08:05 AM
Okay...I got a hold of a good code which allows an image, when its link is clicked, to appear in a new but size controlled window...works nicely...for one image. Here is the code I am using:

<html>
<head>

<script type="text/javascript">
function openwindow()
{
window.open("pics/elderman","my_new_window","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=yes, width=400, height=400")
}
</script>

</head>
<body>

<form>
<input type="button"
value="Open Window"
onclick="openwindow()">
</form>

</body>
</html>

So I repeat the code and have it link to another image..I even edited out any extra Form tags and when I tested it, I thought it was working only to find that not only did the second button link to my second image but the first button linked to my second image too.

I tried separating the codes using a tablebut no go...I tried using part of the code, the "window.open part...still nothing. So I do not know what I did wrong...secondly how do I center my images in the windows?...Thanks

Fang
09-01-2003, 08:13 AM
I think this was answered here (http://forums.webdeveloper.com/showthread.php?s=&threadid=15566&highlight=menubar%3Dno)

sciguyryan
09-01-2003, 08:15 AM
hi,


i think the problem is in the fact that you have one function defined to two buttons. if you want bothe buttons to link to different pictures i would think that you would need two functions each defining a different location for a different picture.


so, just make a copy of your original one and do this:L


function openwindow1()
{
window.open("collo","my_new_window","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=yes, width=400, height=400")
}

at least i think that is how i think its done:rolleyes: .

you could ask this question in the javascript forum for a more detailed answer.


hope that helped.

Charles
09-01-2003, 08:21 AM
Originally posted by Dark Dragon
I got a hold of a good code...Actually you didn't. There are a number of errors there and you are in danger of making a javaScript dependant page.

Start with something that works in valid HTML.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<title>Example</title>
<form action="http://www.bettiepage.com/images/photos/bikini/bikini1.jpg">
<div>
<button type="submit">Bettie Page 1</button>
</div>
</form>
<form action="http://www.bettiepage.com/images/photos/bikini/bikini2.jpg">
<div>
<button type="submit">Bettie Page 2</button>
</div>
</form>

And then add the JavaScript :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<title>Example</title>
<form action="http://www.bettiepage.com/images/photos/bikini/bikini1.jpg" onsubmit="window.open(this.action, '', 'height=400,width=400,scrollbars'); return false">
<div>
<button type="submit">Bettie Page 1</button>
</div>
</form>
<form action="http://www.bettiepage.com/images/photos/bikini/bikini2.jpg" onsubmit="window.open(this.action, '', 'height=400,width=400,scrollbars'); return false">
<div>
<button type="submit">Bettie Page 2</button>
</div>
</form>

Dark Dragon
09-01-2003, 08:31 AM
Thanks everyone but my head is already spinning form this...Charles, I am gonna try your code and see what I can do with it..thanks

Aronya1
09-02-2003, 06:41 PM
Why are you using a button to open a window? Why not create an image that LOOKS like a button, if that's what you want, link it to your image, then use target=_blank in your href tag?