DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   JavaScript / DHTML / AJAX (http://www.daniweb.com/forums/forum117.html)
-   -   Pop-up attribute question (http://www.daniweb.com/forums/thread35208.html)

venetian_jigsaw Nov 11th, 2005 11:09 am
Pop-up attribute question
 
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['modelnum']; ?>")'><img src='../images/products/<?php echo $myrow ["imgsm"]; ?>' border='0' /></td>
<?php
}
?>

tgreer Nov 11th, 2005 12:57 pm
Re: Pop-up attribute question
 
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>


venetian_jigsaw Nov 11th, 2005 3:02 pm
Re: Pop-up attribute question
 
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

tgreer Nov 11th, 2005 3:24 pm
Re: Pop-up attribute question
 
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.

venetian_jigsaw Nov 11th, 2005 3:37 pm
Re: Pop-up attribute question
 
Thanks Thomas...that seems to have doe the trick!

venetian_jigsaw Sep 3rd, 2008 2:14 pm
Re: Pop-up attribute question
 
This is a test

langsor Sep 3rd, 2008 4:04 pm
Re: Pop-up attribute question
 
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.


All times are GMT -4. The time now is 9:17 am.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC