JavaScript - How To Save Url As Text File In Chrome Using Javascript
hi,
i want to create a extension for chrome using which i can save the current tab url in a text file. thanks sanjay Similar TutorialsHello, i m new Javascript but knows basics of functions etc. ive created a website, which also has field to Submit Email addresses for newsletters.. Now, i have a TextBox (for users to write email addresses) and a Submit button in which i want to call a Javascipt script function which OnClick takes the value(email address) from the textbox and saves it to a .txt file on server. i think i am just missing a single line, the function name which will store the value.. i searched ovr the net but didnt find it.. plz help mee. Thankyou! This is code use to save XML file using Javascipt but it can't not save full Processing Instruction, example we have PI is <?xml version="1.0" encoding="utf8"> when run the code then PI is saved with <?xml version="1.0"> and sometime it doesn't word. Please help me fix, thanks PHP Code: function SaveXML(xmlDoc,filename) { var outputXML = xmlDoc.xml; var mfObj = new ActiveXObject("Scripting.FileSystemObject"); var absPath = getPath(); var file = mfObj.CreateTextFile(absPath + filename, true); file.Write(outputXML); file.Close(); } function getPath() { var path = document.location; var str = new String(path); var end = str.lastIndexOf("/"); var absolutePath = str.substring(8, end) + "/"; absolutePath = absolutePath.replace(/%20/g, " "); return absolutePath; } Hello, I am building a web application that has quotes on it. I am planning on having all the quotes stored in a .txt file. A line space would separate the quotes. Example: "Blah Blah" "Idk what blah" "sure you do" Would this be using Javascript to pull the quotes from the txt file for use in my page be best? I need it to pull all the quotes. Reason for having it like this, I am also planning on having a random quote page where it just pulls 1 quote instead of showing all of them. I'm also open to other ideas here! David Faircloth Im trying to use javascript to search a text file. text file is like this... 1111111[TAB]Project Name[TAB]Application1 2222222[TAB]Project Name[TAB]Application2 Im trying to get the javascript to let a user search for number or project name, if found it displays all the info if found. application1 or application2 (whatever is in the 3rd area) The text file can also be seperated by commas, either way is fine. can anyone help with this. ? Somebody had posted this query on how to read text files using JavaScript.......can't find that post now... Anyways, though it's not possible to read text-files using JavaScript it is possible to read XML files using it. Here is an XML based JavaScript Ticker http://www.dynamicdrive.com/dynamicindex2/xmlticker.htm It works only on browsers supporting XML (IE) Enjoy! Hi I have written the following code to read contents of a text file using FileReader object of HTML 5 for Google Chrome. Quote: <script> function handle_files(files) { var i; if (checkBrowser("Chrome")) { for (i = 0; i < files.length; i++) { file = files[i]; var reader = new FileReader(); ret = []; reader.onload = function (e) { console.log(e.target.result) } reader.onerror = function (stuff) { console.log("error", stuff) console.log(stuff.getMessage()) } text = reader.readAsText(file[i]); alert(text); } } } </script> ---------------------- <input type="file" multiple="multiple" onchange="handle_files(this.files)"> Unfortunately, the variable text always displays as undefined. Everything above the line text = reader.readAsText(file[0]); works fine. How can I fix it?. Or is there any other solution to read a text file using HTML5/JavaScript on Chrome? Thanks in advance. Hey Guys, I'm working on a Gameserver for a Game, written in JavaScript. I want to save all console.log()'s with Timestamp into a txt-file but I don't know how :/ Could you help me with it and tell me how I can do this? for example, I want to save User-Logins into the logs. This is the code I'm using right now. Code: case "LOGIN": var data = PacketModels.login.parse(datapacket); User.login(data.username, data.password, data.is_banned, data.is_online, function(result, user){ if(result){ if(user.is_banned == 1){ console.log("[WARNING] ".red + data.username + " tried to login. It failed because the User is banned!"); c.socket.write(packet.build(["LOGIN", "ISBANNED"])); }else if(user.is_banned == 0){ if(user.is_online == 1){ console.log("[WARNING] ".red + data.username + " tried to login. It failed because the User is already online!"); c.socket.write(packet.build(["LOGIN", "ALREADYLOGGEDIN"])); }else if(user.is_online == 0){ c.user = user; c.enterroom(c.user.current_room); c.user.is_online = 1; c.user.save(); c.socket.write(packet.build(["LOGIN", "TRUE", c.user.current_room, c.user.pos_x, c.user.pos_y, c.user.username])); console.log("[INFO] ".blue + data.username + " has logged in on Map:[" + (c.user.current_room_name).blue + "] X:[" + String(c.user.pos_x).blue + "] Y:[" + String(c.user.pos_y).blue + "]"); } } ... Reply With Quote 12-22-2014, 02:48 PM #2 sunfighter View Profile View Forum Posts Senior Coder Join Date Jan 2011 Location Missouri Posts 4,830 Thanks 25 Thanked 672 Times in 671 Posts JS will not save a text file. You need to do this with a server side language like PHP and if your going to all of that trouble you might want to study a database at the same time or soon after. I have a ZIP file in the server. I want create a create a save dialog to save the zip file in local machine. The below code works perfectly fine for firefox but not on IE. apparently I want the code to work in IE. this is 4th JS forum I am posting my question......any help is greatly appreciated. <html> <head></head> <script language='javascript'> function JBTRunZip( ){ location.href="IMAN_IMAGE_FILES.zip"; } function download(locate){ window.open(locate) } </script> <body> <button onclick="JBTRunZip()">generateZip</Button> <td><input type ="Button" value ="Scarica" onclick="download('Test.zip');"></td> </body> </html> I have a Java Script that displays a Daily Affirmation on a webpage from an array of 365 Affirmations within the same html webpage file. This makes the html file size way too large. So I would like for the java script to read the array from an external text file on the same website server. Please provide me the Code to insert within my script which will read the array from an external text file - and also the format that the array of 365 lines must be typed into the external text file. I am not a Javascript Programmer - and know nothing about Javascript, so please write your reply at my (lack of) knowledge Level. Thank you in advance! Here is the code I am using. <script language=javascript> <!-- Date.prototype.getDOY = function() {var onejan = new Date(this.getFullYear(),0,1); return Math.ceil((this - onejan) / 86400000);} var today = new Date(); var DOY = today.getDOY(); var HL=new Array() //Configure the following array to hold the 365 HLs for each day of the year HL[1]='HL 1 goes here' HL[2]='HL 2 goes here' HL[3]='HL 3 goes here' // Jump to Day 224 of the year for this example only HL[224]='I am surrounding myself with positive and supportive people. When I nurture relationships that give me energy and enjoyment, I mirror my beliefs that I deserve such gifts.' HL[225]='Today I affirm my own worth and value, and discover that the world agrees with me.' HL[226]='I am sowing seeds based on a healthy belief in my own self-worth. My life is flourishing with growing love, contentment, and exciting possibilities.' HL[227]='HL 227 goes here' HL[228]='HL 228 goes here' // Jump to last HL for Day 365 of year - for this example only HL[365]='HL 365 goes here' document.write(HL[DOY]) //--> </script> Hello all, i am a newbie here. I am starting to programme with javascript. I am designing a website. in This website there is an input with type = text and beside this input, there is another input with type = submit. If i open this website: The default value on the search text is "Enter a text", and if I click submit button, this button can recognize the value of the search text which is "Enter a text". <input id="searchText" type="submit" value="Enter a text"/> <input id="searchSubmit" type="submit" value="Submit"/> And then i modified a little bit. I have this javascript: var searchInput = $('#searchText'); searchInput.focus( function() { searchInput.attr('value', ''); }); The goal is, when I click on the search text, the default text is gone. And it worked. But if i write a new text on the search text, the submit button still recognized the value of search text as empty string. Can anyone please help me?? Thank you I am doing a website project and I am currently designing product page. I have created the text boxes dynamically(as many boxes as the user wants) and he can drag and drop the text boxes in the page. I need to create a dynamic line from one text boxes to other text boxes and delete the test boxes which the user does not want. I have created the dynamic graphic line. I know the values of the text boxes can be saved using php in the backend. But is there any way the values with the dynamically created boxes(with <div></div> elements, not with the text boxes) with values and graphics line can be saved online and the user when log-in again can retrieve the work that he saved? Can we code this either in javascript/php? All -- I have a JavaScript config file called gameSetting.js which contains a bunch of variables which configures a particular game. I also have a shared JavaScript library which uses the variables in gameSetting.js, which I include like so: <script type="text/javascript" src="gameSetting.js" ></script> <script type="text/javascript" src="gameLibrary.js" ></script> In gameSetting.js I have: $(document).ready(function() { // call some functions / classes in gameLibrary.js } in Firefox, Safari, and Chrome, this works fine. However, in IE, when it's parsing gameSetting.js, it complains that the functions that live in gameLibrary.js aren't defined. When it gets to parsing gameLibrary.js, the variables in gameSetting.js are reported as not being defined. I've tried dynamically bootstrapping the gameLibrary file using this function in document.ready for dynamic load... $.getScript("gameLibrary.js"); However, the same problem still happens in IE, where when it parses the files individually it's not taking into context the file/variables that came before, so it's not an out of load order problem. My options a 1) collapsing all the functions in gameLibrary.js and variables in gameSetting.js into one file. However, this is not practical because this is dealing with literally hundreds of games, and having a gameLibrary.js in ONE location for ONE update is what makes most logical sense. 2) figure out a way to get this to work where variables in file1 are accessible to file2 in IE (as it seems they are in other browsers). jQuery seems to be able to have multiple plugins that all refer to the based jQuery-1.3.2.js, so I know there is a way to get this to work. Help appreciated. Nero Hi, I'm trying to call a Js function from a test.js located in a HTML file. I'm getting error message "Object has no method..." in Chrome. But no issues are seen in Firefox. Can any one please let me know how i can fix this. <html> <head> .... .... .... <div> <html> <head> <script src="test.js"></script> <script> function aFunc() { alert ("Inside aFunc"); } </script> </head> <body> </html> .... .... .... </div> </head> </html> test.js function bFunc () { aFunc (); } Hello, i'm trying to insert a dynamic js file which contains multiple functions in it (for the example : function x, function y) and it seems that my google chrome doesn't really like it so much is there anyway you know i can bypass it and make it work and both web browsers code examples: // this is where the js file supposed to go <script id="ScriptFile"> </script> //1.js contains function x and function y document.getElementById('ScriptFile').src = "/Mysite/js/1.js" later on i need to preform some actions with function x & y. Couple more issues i need to explain first there are number of js files (1,2,3 .... n ) which all contain the same functions but with different data so i cant register them hard-coded if i type the function x into the "ScriptFile" block, it does work.. its not the function problem. same goes if i include it as source in the "ScriptFile" block (<script id="ScriptFile" src="/Mysite/js/1.js") this only gives me an error while using chrome, works perfectly fine under explorer the error says it cant find function x. thanks alot! It will be best to use server side scripting like php for it , because user can disable his javascript in that condition your code won't work
Hi to every one. I'w created a mini javascript game for my site where you click on red button as fastest as you can for 10 seonds to achieve as best as you can click numbers per second. And the end score is a variable which I send to a function which reads the array that contains ten best scores and write your score in same array if it's among 10 best. Now I want to make somehow to save that array on server so I could read it on page load to show a high score list, but I'm having trouble to write that array in any kind of data on server that I could read it again from same data. I would be very grateful if someone can help me! I know this was here previously but no solution was found and I wonder if someone could help. JavaScript loads before even DOM is fully loaded but only in Chrome browser. I know I could use setTimeout function but it's now ideal in my case. I am working on a program based on Chromium and have a html page inside it. Page has 4 images that resize (useing javascript) depending on window size Here is load finction Code: window.onload = function(){ window.document.body.onload = initDocument; }; function initDocument() { stretchFit("divMy", "bg"); stretchFit("divG", "bgG"); stretchFit("divTech", "bgTech"); stretchFit("divKB", "bgKB"); } Any ideas how to load function after DOM is loaded? This is a JavaScript sample that works with Internet Explorer and Safari, but not with FireFox and Chrome. If you take the code and save it as test.html open the file with explorer or Safari you will see it works. This is the first time of posted on this forum, sorry if I missed any information. This form posts to a InternetSecure(payment gateway) Sandbox account. [CODE] <head> <title>Variable Payment - JavaScript</title> </head> <script language="javascript"> function getamount() { prod = "::1::P001::Sample Payment::"; pvalue = document.getElementsByName("payvalue")(0).value; amount = pvalue + prod; document.frmdo.Products.value = amount; } </script> <body> <table align="center" width="600"> <tr> <td align="center" valign="middle"><big>View Source For HTML Code<br></big><em><strong>Variable Payment - JavaScript</strong></em><br /></td> </tr> </table> <td align="center" valign="top"> <FORM method=post name="frmdo" action="https://test.internetsecure.com/process.cgi" onsubmit="return getamount();"> <input type="hidden" name="GatewayID" value="106" /> <input type="hidden" name="ReturnURL" value="https://testwww.internetsecure.com/merchants/Demopage.asp?page=THK2" /> <input type="hidden" value="https://testwww.internetsecure.com/merchants/Demopage.asp?page=SAM1" name="xxxCancelURL" /> <input type="hidden" name="Products" value="" /> <table align="center" width="600"> <tr> <td width="300" height="100%" align="right" valign="middle"><font face="Arial, Helvetica, sans-serif" size="2" color="Black">Invoice Number</font></td> <td width="300" height="100%" align="left" valign="middle"><input type="text" id="Invoice Number" name="xxxMerchantInvoiceNumber" size="8" /></td> </tr> <tr> <td width="300" height="100%" align="right" valign="Middle"><font face="Arial, Helvetica, sans-serif" size="2" color="Black">Payment Amount $</font></td> <td width="300" height="100%" align="left" valign="middle"><input type="text" name="payvalue" value="" size=10 style="text-align:right;" /> <font face="Arial, Helvetica, sans-serif" size="2" color="Black"> USD</font></td> </tr> </table> <table align="center" width="600"> <tr> <td width="600" height="100%" align="center" valign="middle"><input type="submit" value="Submit Payment" name="submit" /></td> </tr> </table> <table align="center" width="600"> <tr> <td width="600" height="100%" align="center" valign="middle"> <!-- Copy this Grahpic to your Host and change the URL to point to your server --><IMG ALIGN=CENTER SRC="https://secure.internetsecure.com/images/visa04.gif" WIDTH=37 HEIGHT=23> <!-- Copy this Grahpic to your Host and change the URL to point to your server --><IMG ALIGN=CENTER SRC="https://secure.internetsecure.com/images/mc04.gif" WIDTH=37 HEIGHT=23> <!-- Copy this Grahpic to your Host and change the URL to point to your server --><IMG ALIGN=CENTER SRC="https://secure.internetsecure.com/images/amex04.gif" WIDTH=37 HEIGHT=23> <!-- Copy this Grahpic to your Host and change the URL to point to your server --><IMG ALIGN=CENTER SRC="https://secure.internetsecure.com/images/disc04.gif" WIDTH=37 HEIGHT=23> </td> </tr> </table> <table align="center" width="600"> <tr> <td width="600" height="100%" align="center" valign="middle"><a target="_blank" href="https://testwww.internetsecure.com/cgi-bin/certified.mhtml?merchant_number=106"><img height="33" border="0" align="center" width="98" alt="" src="https://testwww.internetsecure.com/images/ismerch_sm.gif" /></a></td> </tr> </table> </form> [CODE] Hi again all, back with another hopefully easy question to fix. Please check this out in Internet explorer: http://www.lindesigns.us/rma/rmaonline.html I googled for the answer, but could not come up with a good response in terms of my own script on how to make the return code fields EXPAND to full length when pressed like they do in firefox and chrome. Does anyone have a quick fix for this? It's all dynamically loaded except for the first 10 fields (Which i might as well take out anyway), so I'm thinking I have to put something in the javascript somewhere, just no idea what. Thanks a lot! -pcitech |