Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

open new popup window

Status
Not open for further replies.

m79asz

Programmer
Oct 1, 2010
1
NL
instead of opening a page in the same browser window, I want to open the url (e.g. beh.html) in a popup window. How can I change my script that way?


<script type="text/javascript">
function buildArray()
{
var a = buildArray.arguments;

for ( var i=0; i<a.length; i++ )
{
this = a;
}

this.length = a.length;
}


var urls1 = new buildArray("",
"beh.html",
"gen.html");

function go ( which, num, win )
{
var n = which.selectedIndex;

if ( n != 0 )
{
var url = eval ( "urls" + num + "[n]" )
if ( win )
{
openWindow ( url );
}
else
{
location.href = url;
}
}
}


</script>
<form name="form1">

<select name="menu1" onchange="go(this, 1, false)">
<option>OPEN
<option>BEH
<option>GEN
</select>

</form>


 
Can you provide the code for your
Code:
openWindow
method, also worth noting that :

1. You should not use
Code:
EVAL
in your code
2. You HTML should also be valid

so

Code:
<option>GEN

should be :

Code:
<option>GEN</option>

Greg Griffiths
Livelink Certified Developer & ECM Global Star Champion 2005 & 2006
 
Use window.open(); instead of location.href to open the window. Beware though, that some popup blockers may block it if they think its an unwanted popup.

Code:
window.open(url,"Windown Name","attribute1, attribute2,...");


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top