PDA

View Full Version : Improving these two scripts


donbmjr
12-18-2002, 02:33 PM
The first script is a dropdown box that will also
do popups and size, placement etc, it's known weakness is it will not consistently resize sometimes it does and then it does not. Is there a way to improve that weakness and improve the look of the menu as it appears on the home page.

The second script is another dropdown that will be placed in other pages and be brought up be the first
script, is there any conflict with these two working together in many browsers any do you see any weakness
in it

#1

<script Language="JavaScript">
<!--
function popup(url, name, width, height)
{
settings=
"toolbar=yes,location=yes,directories=yes,"+
"status=no,menubar=no,scrollbars=yes,"+
"resizable=yes,width="+width+",height="+height;

MyNewWindow=window.open("http://"+url,name,settings);
}
//-->
</script>


Once the script is added to your page, you can open windows using this syntax for the link tags:

<a href="#" onClick="popup('www.yahoo.com', 'Win1', 300, 300); return false">
Click Here To Go to Yahoo</a>


#2


<BODY>

<SCRIPT LANGUAGE="JavaScript">
var Image_array = new Array();
//new Array("Image location",width,height,"discription image")
Image_array[0] = new Array("houseproud_P.jpg",100,90,"House Proud");
Image_array[1] = new Array("pariscallingP.jpg",100,90,"Paris calling");
Image_array[2] = new Array("frenchsessionsP.jpg",100,90,"French Session");
Image_array[3] = new Array("coverfullonP.jpg",100,90,"Full on");
//If you want to add more images use Image_array[4]= ...


function setf(thisv)
{
img_changer.src = Image_array[thisv][0];
img_changer.style.width = Image_array[thisv][1];
img_changer.style.height = Image_array[thisv][2];
}
</script>

<center>

<select onchange="setf(this.selectedIndex)">
<script language=javascript>
for(i=0;i<Image_array.length;i++)
{
document.write("<option>" + Image_array[i][3]);
}
</script>
</select>

<br><br>
<img name=img_changer border=1>
</center>

<script language=javascript>
setf(0);
</script>



Thanks
Don

beetle
12-18-2002, 04:34 PM
Number one<script Language="JavaScript" type="text/javascript">
<!--
function popup(url, name, width, height)
{
var settings=
"toolbar=yes,location=yes,directories=yes,"+
"status=no,menubar=no,scrollbars=yes,"+
"resizable=yes,width="+width+",height="+height;

// MyNewWindow=window.open("http://"+url,name,settings); <-- Omit red to make line below
MyNewWindow=window.open(url,name,settings);
}
//-->
</script>

<a href="http://www.yahoo.com" target="Win1" onClick="popup(this.href, this.target, 300, 300); return false">
Click Here To Go to Yahoo</a> Number two<script language="JavaScript" type="text/javascript">
var Image_array = new Array();
var i=0;
//new Array("Image location",width,height,"discription image")
Image_array[i++] = new Array("houseproud_P.jpg",100,90,"House Proud");
Image_array[i++] = new Array("pariscallingP.jpg",100,90,"Paris calling");
Image_array[i++] = new Array("frenchsessionsP.jpg",100,90,"French Session");
Image_array[i++] = new Array("coverfullonP.jpg",100,90,"Full on");
//If you want to add more images use Image_array[4]= ...
// Note, the usage of 'i' above makes it easy to change the order of the images without having to keep track of the array indexes


function setf(thisv)
{
img_changer.src = Image_array[thisv][0];
img_changer.style.width = Image_array[thisv][1];
img_changer.style.height = Image_array[thisv][2];
}
</script>

<center>

<select onchange="setf(this.selectedIndex)">
<script language="javascript" type="text/javascript">
for(i=0, len=Image_array.length;i<len;i++)
{
document.write("<option>" + Image_array[E][3] + "</option>");
}
</script>
</select>

<br><br>
<img name="img_changer" border="1">
</center>

<script language="javascript" type="text/javascript">
setf(0);
</script> If you wanted, you could use literal notation for your array as well

var Image_array = [
['houseproud_P.jpg',100,90,'House Proud'],
['pariscallingP.jpg',100,90,'Paris calling'],
['frenchsessionsP.jpg',100,90,'French Session'],
['coverfullonP.jpg',100,90,'Full on']
];

donbmjr
12-19-2002, 12:57 AM
Everything working fine.
I forgot to ask how to bring the popup on the center of the
page I tried some lines from other scripts but they did not work from.

Also is ther a way to bring the popup up from a menu or
rather than a link or maybe from a dropdown menu ,
In the end I will have nearly 30 of these popup windows
with up to 50 links in the dropdown inside it, trying to keep the navigation part under control.

Here is what I am working on, the Cartoon one has your changes for the dropdown menu
I have tested you changes in in the first script on and will put in in shortly, the yahoo link

http://users.adelphia.net/~donbmjr/


Thanks again

Don Miller