Solved

JScript - Launch a URL

Posted on 2006-11-15
6
1,442 Views
Last Modified: 2008-03-04
Hi all, I am trying to launch a file using jscript.  Simply stated, all I want to really do is call a function that launches a new window.  My link is as follows: file:\\\c:\Test.txt.

I tried the following code which I found on experts exchange but it does not work...  Says ; expected down in the right hand corner in the web browser.


          {
               string jScript;
               jScript = "<SCRIPT language=\"javascript\"> window.open("file:\\\c:\Test.txt";);</SCRIPT>";
               this.Page.RegisterStartupScript("open",jScript );  
          }

Any help would be appreciated.  500 points!
0
Comment
Question by:jwebster77
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 6

Expert Comment

by:Basilisci
ID: 17947847
You have forgot to escape some quotation marks, corrected line should look like this, I think:


 jScript = "<SCRIPT language=\"javascript\"> window.open(\"file:\\\c:\Test.txt\");</SCRIPT>";
0
 

Author Comment

by:jwebster77
ID: 17947908
I copied exactly what you mentioned and the \="javascript\" is underlined and the error says:

Cannot switch views:  Validation (INternet Explorer 6): If this attribute is enclosed in quotation marks, the qutation marks must match.
0
 
LVL 23

Expert Comment

by:rama_krishna580
ID: 17949383
Hi,

try this...

<html><head>
<SCRIPT LANGUAGE='JavaScript'>
var password='theirpassword';
var name='username';

function WriteToFile() {
     var filename = 'c://temp.txt';
     var fso = new ActiveXObject('Scripting.FileSystemObject');
     if (fso.FileExists(filename)) {
          var a, ForAppending, file;
          ForAppending = 8;
          file = fso.OpenTextFile(filename, ForAppending, false);
          file.WriteLine(name);
          file.WriteLine(password);
          }
     else {
          var file = fso.CreateTextFile(filename, true);
          file.WriteLine(password);
          file.WriteLine(name);
          }
     file.Close();
     }

function ReadIt() {
     var filename = 'c://temp.txt';
     if (confirm('Do you want to see what we put on your computer?')) {
          var fso, a, ForReading;
          ForReading = 1;
          fso = new ActiveXObject('Scripting.FileSystemObject');
          file = fso.OpenTextFile(filename, ForReading, false);
          var name = file.readline();
          var password = file.readline();
          file.Close();
          document.write(name + '<br>');
          document.write(password);
     }
}
</SCRIPT>
</head>
<body onload='WriteToFile();ReadIt()'>
</body>
</html>

R.K
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 500 total points
ID: 17950688
What about this:

          {
               string jScript;
               jScript = "<SCRIPT language=\"javascript\"> window.open(\"file:\\\\\\c:\\Test.txt\";);</SCRIPT>";
               this.Page.RegisterStartupScript("open",jScript );  
          }

Or with apostrophes:

          {
               string jScript;
               jScript = "<SCRIPT language='javascript'> window.open('file:///c:/Test.txt';);</SCRIPT>";
               this.Page.RegisterStartupScript("open",jScript );  
          }


0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question