Two Questions about the Following Block of Code

G

Greener

May I ask you the following? Two questions about the following block
of code:

1) How to open the file in NON-ReadOnly mode? I tried many things, but
none of them was working.

2) Any problems with the lines with document.write (...), as indicated
below?


<script language="JavaScript">

var ua = navigator.userAgent.toLowerCase();

// Browsers: Netscape has a lot of impostors

bNN = (ua.indexOf('mozilla') != -1 && ua.indexOf('compatible') == -1
&&ua.indexOf('opera') == -1 && ua.indexOf('hotjava') == -1
&&ua.indexOf('webtv') == -1 && ua.indexOf('spoofer') == -1);

bIE = (ua.indexOf('msie') != -1 && ua.indexOf('opera') == -1);

function openFile(strFile)
{
if(bIE)
{
alert("ie " + strFile); //open files this way

if(typeof ActiveXObject != 'undefined')
{
// new ActiveXObject can be called.

var myApp = new ActiveXObject("Excel.Application");

//alert("here " + myApp);

if (myApp != null)
{
myApp.Visible = true;
myApp.Workbooks.Open(strFile);
myApp.Workbooks(strFile).Activate;

}
}
}

else
{
alert("other " + strFile); //opening file another way

// Whenever I include the following two lines, the program wouldn't
run, and I saw "Error on Page" at the left bottom corner, right above
the Toolbar. What's wrong with the following two lines?

document.write("<a href='" + strFile + "'
target="_top">");
document.write("</a>");

}
}
</script>

Thank you for your expertise!
 
G

Greener

Thanks, Lee.

I tried document.write("<a href='" + strFile + "' target='_top'>"); //
OR using '_blank'

It still cannot open the Excel file. My question is,

1) Is the line "document.write( )" indeed the way in Netscape to open
an Excel file if you pass a http:/ link? Is so, why didn't it work?
Are there any other ways to open files in Netscape?

2) In Internet Explorer, I had to use a different way (creating
ActiveX instance shown in my earlier message) to open an Excel file.
How to force opening the file in NON-ReadOnly mode? I tried many
things, but none of them was working.

Thanks millions!

Helena
 
G

Greener

Thanks for response. I tried document.write("<a href='" + strFile + "'
target='_top'>"); // OR using '_blank'

It still cannot open the Excel file. My question is,

1) Is the line "document.write( )" indeed the way in Netscape to open
an Excel file if you pass a http:/ link? Is so, why didn't it work?
Are there any other ways to open files in Netscape?

2) In Internet Explorer, I had to use a different way (creating
ActiveX instance shown in my earlier message) to open an Excel file.
How to force opening the file in NON-ReadOnly mode? I tried many
things, but none of them was working.

Thanks millions!

Helena
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top