I am unable to get my pop-up to resize or hide the toolbar when I select a thumbnail. I entered the width & height in my onclick event, bu that did not seem to work. I am guessing that I probably need to enter the attributes in the function and if so, where do they go?

Thanks for any assistance that you can provide!

<script type="text/javascript">
function openWindow(modelnum)
{
prodWindow=window.open("lgImg.php?modelnum="+modelnum+"","null");
prodWindow.focus();
}
</script>

<?php
while ($myrow = mysql_fetch_array($myresult))
{
?>
<tr>
<td><a href='#' onclick='openWindow("<?php echo $myrow; ?>")'><img src='../images/products/<?php echo $myrow ["imgsm"]; ?>' border='0' /></td>
<?php
}
?>

Recommended Answers

All 6 Replies

The arguments to the window.open() function are: URL, Name, and Features.

URL is self-evident. Name is the name of the opened window, which can be used as an argument for the target attribute of hyperlinks.

Features is an optional list of characteristics of the new window:

For example:

<a href="myimage.gif" 
  onClick="window.open('myimage.gif', 'myWin', 
  'toolbar=no, directories=no, location=no, 
  status=yes, menubar=no, resizable=no, scrollbars=no, 
  width=300, height=200');">my image</a>

Thomas,

I am a little confused: this works only if you are calling a single img on a single page and not multiple img's from a single page (e.g. a catalog). Since multiple img's are called from the db, I wrote a function that would grab the img tied to the modelnum, hence my function is executed in the onclick event. So, do I include the attributes in the function or in the event?

Thanks

Your question, as I understood it, was how to remove the toolbar from your opened window. My response was to show you that the window.open() function has an optional "features" parameter to control this.

You need to change this line in your code:

prodWindow=window.open("lgImg.php?modelnum="+modelnum+"","null");

You are passing in "null" as a name, and leaving off the the feature string. Edit it to pass in the features you desire for the pop-up window.

Thanks Thomas...that seems to have doe the trick!

Member Avatar for langsor

By the way, many browsers now open pop-up windows as tabbed windows. Which means that you cannot hide the scrollbars of the main window... so if this is important you might try a different approach.

css
window {
overflow: hidden;
}

js
var body = document.getElementsByTagName('body').item(0);
body.style.overflow = 'hidden';
...or...
body.style.overflow = 'auto'; // back to normal

Just a thought

Oops, sorry ... I thought you were trying to hide the scrollbars -- my bad.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.