dimamo1983
08-25-2003, 08:22 PM
i finally have a little free time on my hands and would like to learn javascript, but now I'm stuck with the basics - window.open function
I have two books on javascript. One of them says that correct syntax is window.open("address", "name", "parameters"); The other one says that I have to add config= infront of parameters: window.open("address", "name", config="parameters");
Any idea why is that? I mean both ways seem to work, but I'm just wondering...
Now moving on to the actual problem. I'm trying to open a larger-size picture in a new window whenever user clicks on my thumbnail. I don't have any problems doing it inline like:
<a href="#" onClick="window.open('images/pictures/13.jpg', 'blah', config='height=520,width=500,toolbar=no,menubar=no,status=no,scrollbars=no,resizable=no'); return false;">
<img src="images/pictures/thumbs/13.jpg" width="128" height="95" alt="13.jpg" />
</a>
or even easier by sticking onClick inside the img:
<img src="images/pictures/thumbs/20.jpg" width="128" height="83" alt="20.jpg" onClick="window.open('images/pictures/20.jpg', 'blah', config='height=520,width=500,toolbar=no,menubar=no,status=no,scrollbars=no,resizable=no'); return false;" />
however, I have many images and would like to have a function that I can call to open each one of them. Something like showPicture(url, height, width). I tried doing it, but can't get anywhere. It just doesn't do anything, just moves to the top of the pages whenever I click on a thumb. Here is what I have:
<head>
<script type="text/javascript" language="javascript">
function showPicture(url, h, w)
{
var newwindow = window.open(url, url, "height="+h+",width="+w+",toolbar=no,menubar=no,status=no,scrollbars=no,resizable=no");
}
</script>
</head>
<body>
<a href="#" onClick="showPicture('images/pictures/45.jpg', 500,500); return false;
<img src="images/pictures/thumbs/45.jpg" width="128" height="83" alt="45.jpg" />
</a>
</body>
Anyone have any ideas what's going on? :confused:
thanks
dima
I have two books on javascript. One of them says that correct syntax is window.open("address", "name", "parameters"); The other one says that I have to add config= infront of parameters: window.open("address", "name", config="parameters");
Any idea why is that? I mean both ways seem to work, but I'm just wondering...
Now moving on to the actual problem. I'm trying to open a larger-size picture in a new window whenever user clicks on my thumbnail. I don't have any problems doing it inline like:
<a href="#" onClick="window.open('images/pictures/13.jpg', 'blah', config='height=520,width=500,toolbar=no,menubar=no,status=no,scrollbars=no,resizable=no'); return false;">
<img src="images/pictures/thumbs/13.jpg" width="128" height="95" alt="13.jpg" />
</a>
or even easier by sticking onClick inside the img:
<img src="images/pictures/thumbs/20.jpg" width="128" height="83" alt="20.jpg" onClick="window.open('images/pictures/20.jpg', 'blah', config='height=520,width=500,toolbar=no,menubar=no,status=no,scrollbars=no,resizable=no'); return false;" />
however, I have many images and would like to have a function that I can call to open each one of them. Something like showPicture(url, height, width). I tried doing it, but can't get anywhere. It just doesn't do anything, just moves to the top of the pages whenever I click on a thumb. Here is what I have:
<head>
<script type="text/javascript" language="javascript">
function showPicture(url, h, w)
{
var newwindow = window.open(url, url, "height="+h+",width="+w+",toolbar=no,menubar=no,status=no,scrollbars=no,resizable=no");
}
</script>
</head>
<body>
<a href="#" onClick="showPicture('images/pictures/45.jpg', 500,500); return false;
<img src="images/pictures/thumbs/45.jpg" width="128" height="83" alt="45.jpg" />
</a>
</body>
Anyone have any ideas what's going on? :confused:
thanks
dima