Click to See Complete Forum and Search --> : what is wrong in this script?


_LOBO_
07-11-2003, 09:47 AM
What is wrong in this script? :confused:


<body>
<form name="take">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%"><select name="take2" size="5">
<option selected value="http://www.javascriptkit.com">JavaScript Kit frontpage</option>
<option value="http://www.javascriptkit.com/javaindex.htm">JavaScript Tutorials</option>
<option value="http://www.javascriptkit.com/cutpastejava.htm">Free JavaScripts</option>
<option value="http://www.javascriptkit.com/howto/webbuild.htm">Web Building Tutorials</option>
<option value="http://www.javascriptkit.com/java/javafront.htm">Free Java Applets</option>
<option value="http://www.javascriptkit.com/frontpage.htm">FrontPage Tutorials</option>
<option value="http://www.cnn.com">CNN</option>
<option value="http://www.microsoft.com">Microsoft</option>
<option value="http://www.netscape.com">Netscape</option>
</select>

<script language="javascript">

// custom window function
function open_win(name,w,h)
{
// sets location
url = document.take.take2.options[document.take.take2.selectedIndex].value;

// set vars to center window
froml = (screen.width/2) - (w/2);
fromt = (screen.heigh/2) - (h/2);

set = 'height='+h
+ ',width='+w
+ ',toolbar=no'
+ ',menubar=no'
+ ',scrollbars=no'
+ ',resizable=no'
+ ',location=no'
+ ',directories=no'
+ ',status=no'
+ ',left='+froml
+ ',top='+fromt;

open(url,name,set);
}
</script>

</td>
</tr>
<tr>
<td width="100%"><div align="center"><center><p><input type="button"
value="Take Me There!" name="B1" onClick="taking()"></td>
</tr>
</table>
</form>

</body>:confused:

Khalid Ali
07-11-2003, 09:58 AM
Whats wrong with this script???

The lest you could do is to write down what is it you expect it to do and whats the erro you are getting instead..

freefall
07-11-2003, 10:00 AM
Well let em give you some hints. First off, you never use the open_win() function. Next, you have the submit button fire a function called taking(), which doesn't exist. When I get home and have some more time I can help you out here if you can't get this yourself.

Also, next time you have a problem with a script, describe the problem, don't just say there is one.
- Ian

_LOBO_
07-11-2003, 10:24 AM
you are right freefall!

and thanks guys for stop here.

the problem:

I want to launch a pop up using this script, the original only launch a new web page.


original script here (http://www.javascriptkit.com/script/cut147.shtml)

_LOBO_
07-11-2003, 10:36 AM
I made this and now it works, but the pop up is not centred in the screen, is in the middle but at the top of the screen.


my changes:
<td width="100%"><p><input type="button"
value="Take Me There!" name="B1" onClick="open_win('name',800,600)"></td>


And someone can tell me if this script is optimized? Thank you

Mr J
07-11-2003, 03:07 PM
Its a typo

fromt = (screen.heigh/2) - (h/2);


should be

fromt = (screen.height/2) - (h/2);

_LOBO_
07-14-2003, 03:24 AM
Thanks Mr. J :D