Two Questions about the Following Block of Code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Greener

    Two Questions about the Following Block of Code

    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="JavaS cript">

    var ua = navigator.userA gent.toLowerCas e();

    // Browsers: Netscape has a lot of impostors

    bNN = (ua.indexOf('mo zilla') != -1 && ua.indexOf('com patible') == -1
    &&ua.indexOf('o pera') == -1 && ua.indexOf('hot java') == -1
    &&ua.indexOf('w ebtv') == -1 && ua.indexOf('spo ofer') == -1);

    bIE = (ua.indexOf('ms ie') != -1 && ua.indexOf('ope ra') == -1);

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

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

    var myApp = new ActiveXObject(" Excel.Applicati on");

    //alert("here " + myApp);

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

    }
    }
    }

    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!
  • Lee

    #2
    Re: Two Questions about the Following Block of Code

    Greener said:
    [color=blue]
    >2) Any problems with the lines with document.write (...), as indicated
    >below?[/color]
    [color=blue]
    > document.write( "<a href='" + strFile + "' target="_top">" );[/color]

    Should be:

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

    Comment

    • HikksNotAtHome

      #3
      Re: Two Questions about the Following Block of Code

      >From: helena1995@yaho o.com (Greener)

      <snip>
      [color=blue]
      ><script language="JavaS cript">[/color]

      Language attribute is deprecated in favor of the type attribute:
      text="type/javascript"

      <FAQENTRY>
      type="text/javascript" in favor of language="javas cript"
      </FAQENTRY>

      Not sure on a wording, but its seen a lot here :-(
      [color=blue]
      >var ua = navigator.userA gent.toLowerCas e();
      >
      >// Browsers: Netscape has a lot of impostors[/color]

      Netscape is not the only one with imposters. Most are imposters of Mozilla
      though.

      [color=blue]
      >bNN = (ua.indexOf('mo zilla') != -1 && ua.indexOf('com patible') == -1
      >&&ua.indexOf(' opera') == -1 && ua.indexOf('hot java') == -1
      >&&ua.indexOf(' webtv') == -1 && ua.indexOf('spo ofer') == -1);[/color]


      [color=blue]
      >bIE = (ua.indexOf('ms ie') != -1 && ua.indexOf('ope ra') == -1);[/color]

      AOL passes the bIE test, but you won't open a document this way in it.

      The browser is irrelevant. The test for ActiveXObject suffices. Browsers that
      support it (whether IE or not) will support it, those that don't will move on
      to the else, again making the browser detection nothing more than an extra set
      of un-needed code.

      Consult the group FAQ with regards to Browser Detection.

      [color=blue]
      >// 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?[/color]

      Double click on the Yellow ! and it will show you an exact error message
      (although the solution to it has already been posted) and on the error window,
      check the "Always show this message" checkbox.
      --
      Randy

      Comment

      • Greener

        #4
        Re: Two Questions about the Following Block of Code

        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



        Lee <REM0VElbspamtr ap@cox.net> wrote in message news:<bm26nv02i b4@drn.newsguy. com>...[color=blue]
        > Greener said:
        >[color=green]
        > >2) Any problems with the lines with document.write (...), as indicated
        > >below?[/color]
        >[color=green]
        > > document.write( "<a href='" + strFile + "' target="_top">" );[/color]
        >
        > Should be:
        >
        > document.write( "<a href='" + strFile + "' target='_top'>" );[/color]

        Comment

        • Greener

          #5
          Re: Two Questions about the Following Block of Code

          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



          hikksnotathome@ aol.com (HikksNotAtHome ) wrote in message news:<200310082 25410.21542.000 00503@mb-m02.aol.com>...[color=blue][color=green]
          > >From: helena1995@yaho o.com (Greener)[/color]
          >
          > <snip>
          >[color=green]
          > ><script language="JavaS cript">[/color]
          >
          > Language attribute is deprecated in favor of the type attribute:
          > text="type/javascript"
          >
          > <FAQENTRY>
          > type="text/javascript" in favor of language="javas cript"
          > </FAQENTRY>
          >
          > Not sure on a wording, but its seen a lot here :-(
          >[color=green]
          > >var ua = navigator.userA gent.toLowerCas e();
          > >
          > >// Browsers: Netscape has a lot of impostors[/color]
          >
          > Netscape is not the only one with imposters. Most are imposters of Mozilla
          > though.
          >
          >[color=green]
          > >bNN = (ua.indexOf('mo zilla') != -1 && ua.indexOf('com patible') == -1
          > >&&ua.indexOf(' opera') == -1 && ua.indexOf('hot java') == -1
          > >&&ua.indexOf(' webtv') == -1 && ua.indexOf('spo ofer') == -1);[/color]
          >
          >
          >[color=green]
          > >bIE = (ua.indexOf('ms ie') != -1 && ua.indexOf('ope ra') == -1);[/color]
          >
          > AOL passes the bIE test, but you won't open a document this way in it.
          >
          > The browser is irrelevant. The test for ActiveXObject suffices. Browsers that
          > support it (whether IE or not) will support it, those that don't will move on
          > to the else, again making the browser detection nothing more than an extra set
          > of un-needed code.
          >
          > Consult the group FAQ with regards to Browser Detection.
          >
          >[color=green]
          > >// 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?[/color]
          >
          > Double click on the Yellow ! and it will show you an exact error message
          > (although the solution to it has already been posted) and on the error window,
          > check the "Always show this message" checkbox.[/color]

          Comment

          Working...