JavaScript - File Js Interaction File .js ?
help me!
im have 2 file .js file 1.js code: document.write("<script src=2.js></script>") document.write(f) file 2.js code: var f="hello" im want run 1.js get variable of file 2.js by 3.html but don't run! code 3.html <script src=1.js></script> Similar TutorialsI can get this code to take two separate sections of a file which are not beside each other and write them into another file. It always comes up as a single full line of the code instead of the sections I want. The code includes the student number first name last name and three results of assignments. I want the code to write the student number and three results of all the students into a file and then work out the average of the student results. Can you help? Code: try{ while (in.hasNextLine()) { String line = in.nextLine(); out.println( line); int i=0; if(!Character.isDigit(line.charAt(i))) { i++; } studentStringNumber = line.substring(0, i); String stringResult = line.substring(i); studentStringNumber = studentStringNumber.trim(); stringResults = stringResults.trim(); double stringResultsValue = Double.parseDouble(stringResults.trim()); stringResults = in.nextLine(); studentStringNumber = in.nextLine(); studentNumber = Integer.parseInt(studentStringNumber); if(in.hasNextInt()) { int value = in.nextInt(); } results = Double.parseDouble(stringResults); if(in.hasNextDouble()) { double value = in.nextDouble(); } Scanner lineScanner = new Scanner(line); studentStringNumber = lineScanner.next(); while(!lineScanner.hasNextDouble()) { studentStringNumber = studentStringNumber+ " " +lineScanner.next(); } stringResultsValue = lineScanner.nextDouble(); } } Hi, Can someone tell me what I am doing wrong. Script works on the first attachment but not the other two? Code: <script type="text/javascript" language="JavaScript"><!-- function ExtensionsOkay() { var extension = new Array(); var fieldvalue = new Array(); fieldvalue[0] = document.customApp.attachment_1.value; fieldvalue[1] = document.customApp.attachment_2.value; fieldvalue[2] = document.customApp.attachment_3.value; extension[0] = ".doc"; extension[1] = ".docx"; extension[2] = ".txt"; extension[3] = ".pdf"; // No other customization needed. for(var f = 0; f < fieldvalue.length; f++) { var thisext = fieldvalue[f].substr(fieldvalue[f].lastIndexOf('.')); for(var i = 0; i < extension.length; i++) { if(thisext == extension[i]) { return true; } } alert("Your upload field " + f + " contains an unapproved file name."); return false; } } //--></script> Hello all, I am new here and have a question about a AP Div I am using as a dropin. It drops in when the page loads and I would like it to only drop in if a visitor clicks a link I designate as the dropin link. Can someone please tell me how to accomplish this? I am pasting in the js file and I will also need to know how to set up the "a href" link to call the dropin! Thanks is advance for any help you may give! Code: // JavaScript Document var ie=document.all var dom=document.getElementById var ns4=document.layers var calunits=document.layers? "" : "px" var bouncelimit=32 //(must be divisible by 8) var direction="up" function initbox(){ if (!dom&&!ie&&!ns4) return crossobj=(dom)?document.getElementById("dropin").style : ie? document.all.dropin : document.dropin scroll_top=(ie)? truebody().scrollTop : window.pageYOffset crossobj.top=scroll_top-250+calunits crossobj.visibility=(dom||ie)? "visible" : "show" dropstart=setInterval("dropin()",50) } function dropin(){ scroll_top=(ie)? truebody().scrollTop : window.pageYOffset if (parseInt(crossobj.top)<100+scroll_top) crossobj.top=parseInt(crossobj.top)+40+calunits else{ clearInterval(dropstart) bouncestart=setInterval("bouncein()",50) } } function bouncein(){ crossobj.top=parseInt(crossobj.top)-bouncelimit+calunits if (bouncelimit<0) bouncelimit+=8 bouncelimit=bouncelimit*-1 if (bouncelimit==0){ clearInterval(bouncestart) } } function dismissbox(){ if (window.bouncestart) clearInterval(bouncestart) crossobj.visibility="hidden" } function truebody(){ return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body } window.onload=window.setTimeout(initbox,5000); Does anyone know how to accomplish this? I got the html file to show but none of the text in the file will show.
Hi i am using javascript for the first time and i have a problem .I have 2 files html and javascript file in seperate but i donot know how to make them work .the code is down below .Thanks in advance for help. HTML <!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <meta name="description" content="Instagram API - usage" /> <meta charset=utf-8 /> <title></title> </head> <body> <input id="lat_input" type="number" value="60.221374"/> <input id="lng_input" type="number" value="24.805391"/> <button id="search_location">Search</button><br/> <button id="get_popular">Get popular</button> <div id="images"></div> </body> </html> Javascript file // API DOCUMENTATION: // Instagram Developer Documentation var clientId = 'e7538f47e197479d8d32a63ae3ae4cd2'; $('#search_location').click(function () { getMediaByLocation($('#lat_input').val(), $('#lng_input').val()); }); $('#get_popular').click(function () { getPopularImages(); }); function getMediaByLocation(lat, lng) { var o = { lat: lat, lng: lng, client_id: clientId }; $.getJSON('https://api.instagram.com/v1/media/search?callback=?', o, function (response) { processImages(response.data); }); } function getPopularImages() { var o = { client_id: clientId }; $.getJSON('https://api.instagram.com/v1/media/popular?callback=?', o, function (response) { processImages(response.data); }); } function processImages(array) { $('#images').empty(); $.each(array, function (index, element) { var fs = $('<fieldset>').appendTo('#images'); $('<img>').attr('src', element.images.low_resolution.url).appendTo(fs); if (element.caption) { $('<pre>').text(element.caption.text).appendTo(fs); } $.each(element.comments.data, function (index, comment) { $('<pre>').text('Comment from ' + comment.from.full_name + ': ' + comment.text).appendTo(fs); }); }); } 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 I tried to follow directions here http://www.javascriptkit.com/javatut...ernalphp.shtml and here http://codingforums.com/showpost.php...91&postcount=4 without any luck. Data is looked up from a MySQL database via .php file and then I want javascript inserted into the .js file which includes the data from the query lookup in the .php file. If I load the .php file - everything looks good. But nothing shows in the .js file. Below is the contents of the .php file which is located at http://blackburnseminars.com/wp-cont...is_prices.php: Code: <?php //PHP SCRIPT: get_regis_prices.php header('Content-type: application/x-javascript'); //connect to database mysql_connect("localhost","username","password"); //(host, username, password) //specify database mysql_select_db("dbname") or die("Unable to select database"); //select which database we're using $str="\r"; //CRLF $result = mysql_query("select * from table_name"); while ($row = mysql_fetch_object($result)) { echo "document.write(var fee = \"\";)".$str; echo "document.write(if (studentTypeAbbrev == \"A\"))".$str; echo "document.write({)".$str; echo "document.write(if (creditHours==1) fee =" . $row->atty_crs1.";)".$str; echo "document.write(if (creditHours==3) fee =" . $row->atty_crs3.";)".$str; echo "document.write(document.write(if (creditHours==6) fee =".$row->atty_crs6.";)".$str; echo "document.write(})".$str; echo "document.write(else if (studentTypeAbbrev == \"P\"))".$str; echo "document.write({)".$str; echo "document.write(if (creditHours==3) fee =" . $row->para_crs3.";)".$str; echo "document.write(if (creditHours==6) fee =" . $row->para_crs6.";)".$str; echo "document.write(})".$str; echo "document.write(else if (studentTypeAbbrev == \"J\"))".$str; echo "document.write({)".$str; echo "document.write(fee =" . $row->judge.";)".$str; echo "document.write(})".$str; } ?> The .js file has this line inserted where I want the javascript from the .php file to go: Code: <script type="application/x-javascript" src="http://blackburnseminars.com/wp-content/themes/blackburn/get_regis_prices.php"></script> ...but the code from the .php file doesn't show when I load the .js file. Can anyone tell me what I am doing wrong? Also, do I need to enclose the lines inside document.write()? - (I'm not clear on that) Thanks much Tom Esker Ok so I'm playing around with writing scripts reading through JavaScript: The Definitive Guide and I'm on the Section "Relationships Between Frames". All i'm trying to do is change the background color of the <div id=iframewrap> element, which is inside the iframe, by clicking on the paragraph that says "Click Me", which is inside the iframe's parent window. I have everything I tried below along with the error message recieved by firebug. I Cant figure it out. HTML Code: <p>Click below to change the style of the iframe</p> <p style="color:blue" onClick="chngFrameStyle()">Click Me</p> <iframe id="fone" name="fone" src="OreillyCh14v2Iframe.html" width="50%" height="400px" ></iframe> The iframe Code: <div id="iframewrap" > <h1>Iframe Window</h1> <div id="iframeparagraph"><p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa <strong>strong</strong>. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede <a class="external ext" href="#">link</a> mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi.</p></div> </div> JavaScript Code: function chngFrameStyle() { /* var frameone = window.frames['fone']; frameone.document.getElementByID("iframewrap").style.backgroundColor = "#444"; frameone.document.getElementByID("iframewrap").style.color = "white"; Didn't Work :-{ Firebug Error: frameone.document.getElementByID is not a function */ /* window.frames[0].document.getElementByID("iframewrap").style.backgroundColor = "#444"; window.frames[0].document.getElementByID("iframewrap").style.color = "white"; Didn't Work :-{ Firebug Error: window.frames[0].document.getElementByID is not a function */ /* var iframeone = document.getElementById("fone"); iframeone.document.getElementByID("iframewrap").style.backgroundColor = "#444"; iframeone.document.getElementByID("iframewrap").style.color = "white"; Didn't Work :-{ Firebug Error: iframeone.document is undefined */ /* frames[0].iframewrap.style.color = "white"; return; Didn't Work :-{ Firebug Error: frames[0].iframewrap is undefined */ }; Is it possible to use GetVariable() on a variable outside the Main scene timeline? Im trying to get a variable that is set on "sprite 479" that is gonna run on frame #2.. the variable name is "myVariable" Code: function getElement() { var FlashArr = document.getElementsByName('myFlash'); return FlashArr[FlashArr.length-1]; } alert(getElement().GetVariable("myVariable")); I can only get variables located on the MainMovie sprite. Thank you. I need to interact with application in a way that is being used by mouse and some keyboard clicking like save a text file to a desired location with a desired name by the java script file. Can you give me some information how to do that, and where to get information for that?
Hey all, Whenever firebug detects a js error on a page, it prevents you from interacting with the page, so you can't scroll, you can't click, you can't do anything except close the window. Anyway around this? Thanks. Hello, I am looking for some strong resources about the topics above. I am trying to create a map for my website that visualizes Americas opinions on who will win the 2012 election... Obama vs the Republicans. I have a data set that will be the base, but I would like to update the map as users take the accompanying poll and as the data set changes. Any ideas or information would be awesome! Thanks hi my website is in php . am using a javascript code to open a file . Code: function dec() { window.open("www.test.com/files/2010/test.pdf"); } when i click the hyperlink connected to this function , a browser window is opened .path to the file will be dispaled in the address bar i dont want it like tat. i need to open only the file test.pdf , not in browser window so that path will not be seen . pls help. hi my website is in php . am using a javascript code to open a file . Code: function dec() { window.open("www.test.com/files/2010/test.pdf"); } when i click the hyperlink connected to this function , a browser window is opened .path to the file will be dispaled in the address bar i dont want it like tat. i need to open only the file test.pdf , not in browser window so that path will not be seen . pls help. I am recieving an error of Access Denied in a HTA file when the self.ResizeTo is called in the following code on Line 59 any help would be great. <html> <title>Personal Folder Creator</title> <HTA:APPLICATION ID="objPersonalFolderCreator" APPLICATIONNAME="PersonalFolderCreator" WINDOWSTATE="normal" > <head> <style> BODY { font-family: verdana; font-size: 8pt; } H2 { color: blue; } .Table { font-size: 10pt; border-width: thin; border-style: solid; padding: 10px; } .ResultsTable { border-width: thin; border-style: solid; font-size: 8pt; } </style> '******************************************************************** '* BEGIN_SCRIPT '******************************************************************** <script language="vbscript"> Option Explicit Dim objShell, objFSO Dim strServer, strPath strServer = "TWB-FLS-PR-01" strPath = "Personal" Sub Window_Onload Set objShell = CreateObject("WScript.Shell") Set objFSO = CreateObject("Scripting.FileSystemObject") ParentFolder.Disabled = True SubmitButton.Disabled = True PopulateParentFolders self.Focus() self.ResizeTo 720,410 UserID.Focus() End Sub Sub PopulateParentFolders Dim objFolder, objTempFolder, strTempPath strTempPath = "\\" & strServer & "\" & strPath Set objFolder = objFSO.GetFolder(strTempPath) For Each objTempFolder In objFolder.SubFolders Dim objoption Set objOption = Document.CreateElement("OPTION") objOption.Text = objTempFolder.Name objOption.Value = objTempFolder.Name ParentFolder.Add(objOption) Next End Sub Sub LookupButton_OnClick() Dim objUser Set objUser = GetObject("WinNT://PRDS/" & UserID.Value) lblUserName.innerText = objUser.FullName If InStr(lblUserName.innerText, "(") > 0 Then lblSubFolder.innerText = Mid(lblUserName.innerText, 1, InStr(lblUserName.innerText, "(") - 1) ElseIf InStr(lblUserName.innerText, "[") > 0 Then lblSubFolder.innerText = Mid(lblUserName.innerText, 1, InStr(lblUserName.innerText, "[") - 1) End If ParentFolder.Disabled = False SubmitButton.Disabled = False LookupButton.Disabled = True UserID.Disabled = True lblStatus.innerHTML = "Select Parent Folder - DEFAULT is PERSONAL." End Sub Sub SubmitButton_OnClick() Dim strCommand Dim intReturn If objFSO.FolderExists(lblTargetFolder.innerText) Then MsgBox "Folder Already Exists!", vbExclamation lblStatus.innerHTML = "<font color='red'>Folder Already Exists.</font>" Exit Sub Else If MsgBox("Create the Personal Folder:" & vbNewLine & lblTargetFolder.innerText, vbYesNo + vbQuestion) = vbNo Then Exit Sub End If End If objFSO.CreateFolder(lblTargetFolder.innerText) strCommand = "SUBINACL /file """ & lblTargetFolder.innerText & """ /perm /grant=Administrators=F /grant=SYSTEM=F /grant=PRDS\sor-A-Admins=F /grant=PRDS\" & UserID.Value & "=C /setowner=Administrators" intReturn = objShell.Run(strCommand, 7, True) If intReturn <> 0 Then MsgBox "Error modifying permissions on folder: " & lblTargetFolder.innerText,vbExclamation Else SubmitButton.Disabled = True ParentFolder.Disabled = True MsgBox "Personal Folder Created and Permissions have been set accordingly." & vbNewLine & "Advise Customer the Path to their Personal Folder.", vbInformation lblStatus.innerHTML = "<font color='green'>Folder Created Successfully.</font>" End If End Sub Sub ResetButton_OnClick() ParentFolder.Disabled = True SubmitButton.Disabled = True LookupButton.Disabled = False UserID.Disabled = False ParentFolder.Value = "NUL" lblUserName.innerText = "" lblSubFolder.innerText = "" lblTargetFolder.innerText = "" UserID.Value = "" UserID.Focus() lblStatus.innerHTML = "Enter User ID and Click Lookup." End Sub Sub ParentFolder_OnChange() If ParentFolder.Value = "NUL" Then lblTargetFolder.innerText = "" lblStatus.innerHTML = "Select Parent Folder." Else lblTargetFolder.innerText = "\\" & strServer & "\" & strPath & "\" & ParentFolder.Value & "\" & lblSubFolder.innerText lblStatus.innerHTML = "Ready to Create Folder." End If End Sub </script> '**************************************************************************** '* END_SCRIPT '**************************************************************************** </head> '**************************************************************************** '* HTML Section '**************************************************************************** <body> <h2 align="center">Personal Folder Creator - TWB-FLS-PR-01</h2> <table id='tblInput' class='Table' width="670"> <tr><td><b>User ID: </b></td><td rowspan="2"><input type='text' name='UserID' size='10'><button name='LookupButton'>Lookup</button> <p><select name='ParentFolder'><option value='NUL'>Select</option></select></td> <td rowspan="2"> </td><td rowspan="2" width="324"> <img border="0" src="http://sor-app-pr-01:78/_layouts/images/IT_support.gif" width="324" height="103"></td></tr> <tr><td><b>Parent Folder: </b></td></tr> </table> <br/> <table id='tblSummary' class='Table' width="670"> <tr><td><b>User Name: </b></td><td><div id='lblUserName'> </div></td></tr> <tr><td><b>Personal Folder: </b></td><td><div id='lblSubFolder'> </div></td></tr> <tr><td width='15%'><b>Target Folder: </b></td><td width='85%'><div id='lblTargetFolder'></div></td></tr> <tr><td><b><font color="#FF0000">Status:</font> </b></td><td><font color='red'><div id='lblStatus'>Enter User ID and Click Lookup.</div></font></td></tr> </table> <br/> <div align="left"> <table id='tblButtons' class='Table' style="border-style: solid"> <tr><td> <p align="center"><button name='SubmitButton'> <p align="left">Create Folder</button></td><td> <p align="center"><button name='ResetButton'>Reset</button></td><td> <p align="center"><button name='ExitButton' onClick='self.Close()'>Exit</button></td></tr> </table> </div> <br/> Version 1.1(SOR) : Last Modified 11-08-2008 by Steve Dudley : ITO SOR <br/> Version 1.0 : Created on 04-01-07 by Adam Rutt : ISB DTSG </body> </html> Hi, I am trying to open a FTP file in IE 6, but Its not opening, it throws "Page cannot be Displayed" message. Its work fine in Firefox. Below is the code: <A href="ftp://sysvine.lmt.com/reports/chart.doc">Category Chart</A> even I tried like this: <A href="ftp://username:password@sysvine.lmt.com/reports/chart.doc">Category Chart</A> Please let me know if there is any workaround. Regards, Selvin hello .. can I use som function from c++ library in my java script file ? thanks .. Hey all, I'm fairly new to JavaScript. I learned PHP and now I'm creating a user registration and login system for an application I'm making and I decided I wanted to give JS a try. I'm trying to make a form validation function that will be called when I press the submit button on the form but I want to use an external js file to store all my custom functions. I have the OnClick event in the button with the call to my function inside of that. But where and how on the page to I reference my external file so that the button can call the function? Thanks guys! I've tried every combination I can think of, and I can't figure this out. According to me, if you type a name that matches one of the xml items' names into the box using the following code: Code: Name: <input type="text" id="nameInput"/> <input type="button" onclick="searchLocations()" value="Search Locations"/> function searchLocations() { var input = document.getElementById('nameInput').value; if (!input) { alert("please enter a name"); } else { for (var j = 0; j < gmarkers.length; j++) { if (gmarkers[j].myname == input) { gmarkers[j].show(); } } } } it should show the gmarker with that name... but nothing. If I leave it blank and hit the search button at least I get the alert, so something is working... any suggestions? hi, I am a newbie. Using Java script, I need to open and read CSV file. I need to read the third column values and store in an array. Please help me regarding this. Thanks, Hanumanth. |