Click to See Complete Forum and Search --> : popup win resize to fit random image
bulletz
01-13-2004, 12:03 AM
hello:
got some problem, need to be fix asap.
i currently have 5 banner ads (different sizes) that i want to load in a pop up window (window will resize to fit this images).
i've already have script that loads this images, the problem is, i can't resize the popup window (always in a fixed width and height).
can some point me to a tutorial/code that i can look at?
thanks
Pittimann
01-13-2004, 03:29 AM
Hi!
It might be better if you posted what you already have, so that we can understand, what exactly you are after (e.g. at what point or after which action taken by the user you want the popup to appear etc.).
Cheers - Pit
Working with Windows (http://www.webreference.com/js/tutorial1/index.html)
Khalid Ali
01-13-2004, 09:27 AM
This might be of use (http://www.webapplikations.com/pages/html_js/image_examples/OpenThumbnailImageFullSize.html)
retrocity
01-13-2004, 11:14 AM
hey bulletz, try this:
Make a page to display your "pop-up"s and call it something like popupbanner.htm
add this code:
<script language="JavaScript" type="text/javascript">
<!--
var arrTemp=self.location.href.split ("?") ;
var bannrURL = (arrTemp.length>0)?arrTemp[1]:"";
var NS = (navigator.appName=="Netscape")?true:false;
function FitBannr() {
iWidth = (NS)?window.innerWidth:document.body.clientWidth;
iHeight = (NS)?window.innerHeight:document.body.clientHeight;
iWidth = document.images[0].width - iWidth;
iHeight = document.images[0].height - iHeight;
window.resizeBy (iWidth, iHeight);
sel.focus();
};
//-->
</script>
</HEAD>
-------------------------- in the BODY add this:
<BODY BGCOLOR=#FFFFFF ONLOAD="FitBannr();" LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
<!-- This is where the banner is displayed -->
<script language="JavaScript" type="text/javascript">
<!--
document.write ( "<img src='" + bannrURL + "' border=0>" );
//-->
</SCRIPT>
------------------------- then on the page you are calling it from add this above the (close) HEAD tag:
<script language="JavaScript" type="text/javascript">
<!--
function PopupBannr (sBannrURL) {
window.open ( "popupbanner.htm?" +sBannrURL, "", "resizable=1, HEIGHT=200, WIDTH=200") ;
}
//-->
</script>
----------------------------------add this to whatever link you'll call the pop-up from:
<p align="center"><a href="javascript: PopupBannr ('images/banner1.jpg')"> <font face="Arial" size="1" color="#00FFFF">Banner 1</a></font></p>
hope this helps, let me know,
Retrocity
bulletz
01-13-2004, 09:06 PM
this is the code, i use for my pop-ad.html. this code will randomly display banner img.
<script LANGUAGE="JavaScript">
<!-- Begin
var how_many_ads = 5;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
if (ad==1) {
url="URL_BANNER1"; alt="text here"; banner="images/banner1.gif"; width="800"; height="450";
}
if (ad==2) {
url="URL_BANNER2"; alt="text here"; banner="images/banner2.gif"; width="550"; height="400";
}
if (ad==3) {
url="URL_BANNER3"; alt="text here"; banner="images/banner3.gif"; width="720"; height="300";
}
if (ad==4) {
url="URL_BANNER4"; alt="text here"; banner="images/banner4.gif"; width="200"; height="400";
}
if (ad==5) {
url="URL_BANNER5"; alt="text here"; banner="images/banner5.gif"; width="450"; height="450";
}
document.write('<a href="' + url + '\" target=\"_parent\">');
document.write('<img src="' + banner + '"')
document.write('alt=\"' + alt + '\" border=0>');
// End -->
</SCRIPT>
this is the code im using to call the pop-ad.html for the popup win.
<!-- <SCRIPT LANGUAGE="JavaScript">
function popupPage() {
var page = "pop-ad.html";
windowprops = "width=600,height=600,location=no,scrollbars=auto,menubars=no,toolbars=no,resizable=yes";
window.open(page, "Popup", windowprops);
}
// End -->
</script>
notice that each banner (from pop-ad.html) has different width and height. but the pop up window only has a fixed width and height (600x600), how can i resize the window to fit each banner?
the pop up is called automatically, i dont need to press any button to call
popup win.
thanks
bulletz
01-15-2004, 12:08 AM
?