Auto launch the first attachmnet keeping the Back button healthy

Hi all,

In a database of ours I want one form to auto launch an attachment (.doc or .pdf) when opened in a web browser. As I understand it there is no entry in the Form Properties doing this. Therefore I made a $$HTMLHead field on the top of the form and wrote the following into it:

path := @ReplaceSubstring(@Subset(@DBName; -1); “\”; “/”);

file := @ReplaceSubstring(@Subset(@AttachmentNames; 1); " "; “+”);

@If(@Attachments;

“<script type="text/javascript">”+@NewLine+

"<!-- "+@NewLine+

“location.replace('/” + path + “/0/” + @Text(@DocumentUniqueID) + “/$file/” +

file + “');”+@NewLine+

" -->"+@NewLine+

“”

;“”)

This opens the first attachment when used with a web browser (IE). However, it also breaks the Back button in the web browser so that it is impossible to go back to the previous document in a easy way. The reason, as I see it, is that when the browser steps backwards, it finds the $$HTMLHead field and once again opens the attachment.

Have you an idea how to make the form auto launch the first attachmnet keeping the Back button healthy and good? If you have, please let me know.

Thank you very much in advance.

Jo

Subject: Auto launch the first attachmnet keeping the Back button healthy

Try doing a window.open instead of location.replace. This will pop up the document in a new window instead. You may have problems with popup blockers but, worth a try.