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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

document.window 2

Status
Not open for further replies.

GUJUm0deL

Programmer
Jan 16, 2001
3,676
US
is there a way to use the document.window feature to have more then one page open up from the same function?? what I wanna do is: on a form the user clicks the 'view' link and a new window pops up allowing the user to see the content before d/l it...instead of having many functions and call them individually, can I have one function that calls the approiate file.
this is what I did so far:


<script type=&quot;text/javascript&quot;>
var one = window.mypage.open
var two = window.mypage.open

function openwindow(one,two)

{
window.open(&quot;page1.htm&quot;,&quot;my_window&quot;,&quot;toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,resizable=no,copyhistory=no,width=500,height=500&quot;);
window.open(&quot;page2.htm&quot;,&quot;my_window&quot;,&quot;toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,resizable=no,copyhistory=no,width=500,height=500&quot;);
}
</script>

and this is my form:

<form name=&quot;mypage&quot;>
<a href=javascript:eek:penwindow(one)> view (this will open page1.htm only)</a>
<br><br>
<a href=javascript:eek:penwindow(two)> view (this will open page2.htm only)</a>
</form>

I have not failed; I merely found 100,000 different ways of not succeding...
 
The key lies in the name of the window, if you call your windows different names, they appear as seperate instances. So instead of calling them both &quot;my_window&quot; call them &quot;window1&quot; and &quot;window2&quot; etc...
 
hie
mzongo is correct:

function openit(file,name){
var wnd=window.open(file,name,prefs)
}

<a href=&quot;javascript:eek:penit('page1.htm','w1')&quot;>
<a href=&quot;javascript:eek:penit('page2.htm','w2')&quot;> Victor
 
mzongo and vituz, thax guys it worked...
vituz, you also have to pass the 'prefs' varaible with file and name...like this:

function openwindow(file,name,prefs) {
var wind = window.open(file,name,prefs);
}
</script>
Before I added the 'prefs' in the openwindow(), it wouldn't work, after I added it, it worked...

Thanx guys... I have not failed; I merely found 100,000 different ways of not succeding...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top