Gossamer Forum
Home : Products : DBMan : Customization :

window.open

Quote Reply
window.open
I would like to open a seperate window when clicking on a image.

How would I do this and send it to a sub:

sub whatever{
Quote Reply
Re: window.open In reply to
This goes between the <head> tags, you can use multiple per page if you use a different function names.
Code:
<SCRIPT LANGUAGE="JavaScript">
function ty10wh98() {
win = window.open("http://url/cgi-bin/dbman/db.cgi?db=default&uid=$db_uid&whatever=1", "WIN", "status=no,toolbar=yes,scrollbars=yes,location=no,menu=no,width=450,height=350");
}
</SCRIPT>
Your hyperlink...
Code:
<A HREF="#" onclick="ty10wh98();"><img src="http://URL/to/your/image.gif" border="0" width="150" height="35" alt="Click here"></a>
Quote Reply
Re: window.open In reply to
Ok...but tell me whats wrong with this picture:

<SCRIPT LANGUAGE="JavaScript">
function ty10wh98() {
win = window.open("http://www.nw-home.com/cgi-bin/saleowner/db.cgi?db=king&uid=$db_uid&file_upload_newhome", "WIN", "status=no,toolbar=yes,scrollbars=yes,location=yes,menu=no,width=450,height=350");
}
</SCRIPT>
<A HREF="#" onclick="ty10wh98();"><img src="http://URL/to/your/image.gif" border="0" width="150" height="35" alt="Click here"></a>


sub file_upload_newhome {

print qq|
<table BORDER="0" UNITS="PIXELS" CELLSPACING="0" CELLPADDING="2" WIDTH="476">
<tr VALIGN="TOP">
<td width="476"><font color="#FF0000"><b>Multiple File Upload</b></font><br><br>
This will upload your files to your own directory making it possible for visitors to view exactly what your home looks like.</p>
<P> You have a choice of entering 1 image up to 6. GIF and JPG's only please!!! Their is a limit of 200k per image.
</tr>
</table>


<FORM ENCTYPE="multipart/form-data" ACTION="$db_dir_url/file-upload.cgi" METHOD="POST">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<input type=hidden name="newfilename" value="$rec{$db_key}">
<input type=hidden name="SAVE_DIRECTORY" value="$SAVE_DIRECTORY">
<input type=hidden name="MAXIMUM_UPLOAD" value="$MAXIMUM_UPLOAD">
<input type=hidden name="ALLOWED_EXT" value="$ALLOWED_EXT">
<input type=hidden name="db_key" value="$db_key">
<input type=hidden name="auth_no_authentication" value="$auth_no_authentication">
<input type=hidden name="default_permissions" value="$default_permissions">
<input type=hidden name="auth_allow_default" value="$auth_allow_default">
<input type=hidden name="db_script_url" value="$db_script_url">
<input type=hidden name="auth_dir" value="$auth_dir">
<input type=hidden name="auth_pw_file" value="$auth_pw_file">
<table border="0" width="81%">
<tr>
<td width="27%"><font face="Arial">File 1: </font></td>
<td width="73%"><input type="FILE" name="file-to-upload-01" size="19"></td>
</tr>
<tr>
<td width="27%"><font face="Arial">File 2: </font></td>
<td width="73%"><input type="FILE" name="file-to-upload-02" size="19"></td>
</tr>
<tr>
<td width="27%"><font face="Arial">File 3: </font></td>
<td width="73%"><input type="FILE" name="file-to-upload-03" size="19"></td>
</tr>
<tr>
<td width="27%"><font face="Arial">File 4: </font></td>
<td width="73%"><input type="FILE" name="file-to-upload-04" size="19"></td>
</tr>
<tr>
<td width="27%"><font face="Arial">File 5: </font></td>
<td width="73%"><input type="FILE" name="file-to-upload-05" size="19"></td>
</tr>
<tr>
<td width="27%"><font face="Arial">File 6: </font></td>
<td width="73%"><input type="FILE" name="file-to-upload-06" size="19"></td>
</tr>
</table>

<TABLE BORDER=0>

<TR><TD><INPUT TYPE="SUBMIT" VALUE="Upload File!"></TD>
<TD><INPUT TYPE="RESET" VALUE="Reset Form"></TD></TR>
</TABLE>
</FORM>
</td></tr></table></center></body></html>
|;

}
Quote Reply
Re: window.open In reply to
You don't say what kind of error you're getting, so I'll presume it's a JavaScript one. Try making it file_upload_newhome=1.

A "safer" way of doing it is like this:

<a href="/cgi-bin/saleowner/db.cgi?db=king&uid=$db_uid&file_upload_newhome=1"
target="_new"
onClick="window.open('/cgi-bin/saleowner/db.cgi?db=king&uid=$db_uid&file_upload_newhome=1',
'upload_win',
'status=0,toolbar=1,scrollbars=1,location=1,menu=0,width=450,height=350');
return false">

The difference is, if the user has a JavaScript-enabled browser, and they have it turned on, it works normally and "return false" ensures that the script doesn't return to the html page and follow the href tag. However, if they have an old browser, or JavaScript turned off, you still get your new window, although you have no control over its attributes.

adam

[This message has been edited by dahamsta (edited June 20, 1999).]
Quote Reply
Re: window.open In reply to
Ok..thanks....

my problem is however...once clicked and the window opens...

I always get a "Error: Unknown Action

The database program received a command that it did not understand.


But the window opens just fine....

Quote Reply
Re: window.open In reply to
The problem probably has to do with the file upload mod. I regret ever starting to work with it and I definitely regret posting it to the forum. I thought I knew more than I did, but I know better now.


------------------
JPD





Quote Reply
Re: window.open In reply to
Hey..thats ok...without your testing...this forum would still be in the same state it was a year ago.....

We all just take little steps....
Quote Reply
Re: window.open In reply to
Well, you have to let db.cgi know about the new subroutine. Add this in the sub main in db.cgi whrere dbman directs traffic more or less. Set the permissions for this routine where it says $per_view. Make sure in your URL you have &file_upload_newhome=1 instead of file_upload_newhome.
Code:
elsif ($in{file_upload_newhome'}) { if ($per_view) { &file_upload_newhome; } else { &html_unauth; } }
Hope this helps.

Also note... Hidden fields are not passed to new windows in the AOL browser. You have to include all fields in the FORM ACTION if you want them to work in this fashion, in the AOL browser.

[This message has been edited by ChrisE (edited June 21, 1999).]