I have a webform that creates a word document as it's ouput (yes I know it only works on IE).
function createWordDoc(){
Doctxt = "some text here"
var w=new ActiveXObject("Word.Application");
w.Visible=true;
w.Documents.Add();
w.Selection.Font.Name="Times New Roman";
w.Selection.ParagraphFormat.Alignment = 1;
w.Selection.TypeText(Doctxt);
w.Documents.Save();
}
My issue is with saving the file. At the moment, in the above code, it opens the save dialogue box, and populates the filename field with the first line of text in the document. What I want to be able to do is populate the filename field with a variable filename created by the function. I've tried the snippet below, which works with the dynamic filename, but it autosaves the file to "My Documents" folder without prompting. I need to be able to allow the location to be changed.
var FileName = "Myfile.doc"
w.ActiveDocument.SaveAs(FileName);
My aim: To click on a link (or what looks like a link to the user), and rather than the file linked to opening in the browser or what ever, the save dialogue comes up so they can download it instead.
I would like this to work with images - "click on the thumbnail to download a larger picture" - kind of thing. JPGs specifically.
Can anyone help? I'm sure it's possible in java script, I just can't find it anywhere. I've found a few ASP scraps but nothing concrete.
I am currently developing a page which allows access to music on a server. This music is being streamed, but users are also able to download this music (assuming they have the license to do so). All of the music uploaded is of the .mp3 format, however they have no filetype extensions, and were not named using any particular naming convention. Because of this, I was hoping to change the filename (when a downloaded is initiated) to variables I have stored based on the current song.
I am currently simply opening a new page, in Chrome is looks like this: chrome.tabs.create({ "url": song.url })
Hit presents the user with a prompt to save the file, however, its default name is a random alphanumeric string with no extension, as per their file name on my server. Is there an easy way to do this without renaming all the music server side? I do have the variables song.title and song.artist setup!
Edit: Since this page is only for Chrome users, I listed the code I am using. I understand window.open and was originally using this. It functions the same, and if I need to revert back to using is instead, I shall.
I need to save an HTML page to Word using JavaScript. I have found some script on-line but all of them use the "Save As" procedure which only allows to save in txt and html format. I need it to be in Word.
I have one save button in my html page and as soon as i click that button using javascript's onclick function the html/static page should be saved with .doc extension.As of now i want only the text in the html page to be saved as word document.But if possible suggest me for html pages with images too.I want the logic or sample source code for the above mentioned requirement
I want to show a process dialogue to the client till my process completes on the server. As long as my process dialogue appears, client should not be able to edit the page (or page become inactive); How to do this?
I would like to present the user with a confirmation dialogue box when they click the delete button on my webpage The button is not part of a form but instead is a buttton graphic with the following code:
Code: <td><a href='viewMyListings.php?cmd=delete&listingType=1&accommodationId=$accommodationId' title='Edit listing'><img src='../images/adminDeleteListingBtn.gif' alt='Delete listing'></a></td> Can anyone show me how this can be done? I am assuming javascript is the best solution for this?
I have two prompt dialogue boxes that ask the user the enter their name and their employee number.I am experiencing two errors. The first is, if a user enters their name incorrectly, using numbers for example, there is an error message that asks the user to re-enter their name using a string. If the user ignores the error message and enters a number a second time, the program accepts the entry, which it shouldn't.
The second error has to do with the employee number prompt. The prompt asks the user to enter an employee number that is equal to 6 digits, the program however accepts any number, less than or greater than 6 digits, which it shouldn't.I don't want the user to get away with entering anything incorrectly.
<script type="text/javascript"> // prompt the employer the enter the employee name and number var employName = prompt ("Please enter the employees' name" , " ");[code].....
Way back in the day I did some old school HTML....but after many years not touching a web page I've kind of been thrown straight into the fire with some "wish list" items I'm trying to figure out. I've done plenty of searches and somewhat have an understanding of some of the basics of what I need to do...but I'm not the least bit comfortable with Javascript (I'm just assuming that this the language most applicable to what I'm looking for - and after the experience of my one day crash course with PHP I knew I needed to turn to some experts.
Okay I have a rather large web (about 150 pages) of historical transcriptions created with XHTML (with PHP headers and footers embedded). Generally speaking, I don't much like web pages that have right-click disabled and various other protections in place.....but I'm also the sort to obsessively cite my source material and give proper credits....as a researcher who's hard work has been plagiarized and passed off as the fruits of someone else's labor, I wholly understand why many are inclined to put such walls up.
In my site I show low quality pictures. When someone right clicks an image and selects 'Save Picture As...', I wish to let him save the high quality picture.
When you right click on a link you get the option to save target as...(ie) and save link as...(netscape). Is there some JavaScript to call this function like the JavaScript to open a new window?
I have a long paragraph and I have been asked to display words in red and green in such a way that that fist word should be red, 2nd word should be green, 3rd word should be red and 4th word should be green and so on. For example: this is just a sample.
<script type="text/vbscript"> Dim objWord Sub Btn1_onclick() call OpenDoc("K:DeloitteTeam1 Status reportJavaProgramshi.txt") End Sub
Sub OpenDoc(strLocation)
Set objWord = CreateObject("Word.Application") objWord.Visible = true objWord.Documents.Open strLocation End Sub </script>
I would like to pass the filename used above in the button code below so the above code could be coded only once and then mutiple button code could be used.
Can I subtract the filename form the location.pathname ex: Before = 'file:///c:/afolder/awebsite.html' After = 'file:///c:/afolder/' Or is there any other way to get the directory without the name of the file being veiwed?
This is a simple script I though of to get the filename of container for html.
Note: this only is tested on mozilla firefox 2 on windows vista
document.write("<a style='display:none' id='zFilenameFinder1' href=''>q</a>"); document.write("<a style='display:none' id='zFilenameFinder2' href='b'>q</a>"); var zDocURL = document.getElementById('zFilenameFinder1').href; var zCompareURL = document.getElementById('zFilenameFinder2').href; zCompareURL = zCompareURL.replace('b',''); var zFilename = zDocURL.replace(zCompareURL, ''); alert(zFilename)//filename handler
it works by creating two relative urls. one's href is blank, which when called by link.href returns the absolute value, giving the absolute link the page, then you compare it to a link that has a relative href of "b" which can be compared to the other link to give you the whole url
Is there a way to set the cookie filename with JS?
Currently it is setting it as 'asp/' (my directory). Can i specify it? This is my code:
function setCookie(NameOfCookie, value, expiredays) { // Three variables are used to set the new cookie. // The name of the cookie, the value to be stored, // and finally the number of days until the cookie expires. // The first lines in the function convert // the number of days to a valid date.
var ExpireDate = new Date (); ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
// The next line stores the cookie, simply by assigning // the values to the "document.cookie" object. // Note the date is converted to Greenwich Mean time using // the "toGMTstring()" function.
I have recently come across the need for using the name of the image file within js, but I can't locate it. I am well versed in php, but my js skills are noticeably weak. About 25% of the way into the (partial) lightwindow.js I have placed a comment that shows where I need to access the current image filename.
Code:
This will stop image flickering in IE6 when elements with images are moved try
I'm trying to figure out a way to pass the filename before submission... I think I have to make an onChange command on the file field, but not sure how...
This is what I have done so far: <script type="text/javascript"> function theimage(){ var imgURL = document.getElementById('myfile').value; ste.execCommand("insertimage", imgURL); } </script>
I'm using Joomla. I've got a dropdown which reads the filename from the database. When the user selects it I want an onchange event to open the pdf.I've been at it for 2 days now.
<?php $con = mysql_connect('localhost', 'root', ''); if (!$con)
how to save form values in cookies, etc. for use when re-displaying the forms. for example, after an error has been detected. Naturally, PHP allows you to do this with $_SESSION variables.
But no one seems to have cracked the problem with FORMs having file uploads. Browsers will send the file to the server and the name, but not the path on the client computer (I suppose for security reasons).
So, if you want to re-display the page, you can fill in all the form data in your PHP script so that the user doesn't have to re-enter everything. But, since your PHP script only knows the NAME of the uploaded file, and not the path, whatever your fill in for the "xxx" in <input type="file" value="xxx" /> will be wrong.