JavaScript - Read Info From Other Website(on The Same Web Server)
can I use js to read info (e.g. getElementById('p')) from other web page stored under the same directory of the current webpage? how?
e.g. on this website www.mywebsite.com/home.htm, how to use js to read tag 'p' info from www.mywebsite.com/child1.htm ? thx in advance Similar TutorialsI am wanting to setup a dependant drop down where when a user clicks on the first drop down, it changes the contents of the second. The way I intend to do this is via a csv file. I have found several scripts but I have been unable to get them to work. Two of which a http://answers.yahoo.com/question/in...3114347AA7GYJ7 http://purbayubudi.wordpress.com/200...ng-javascript/ The first is the better option from what I can see. but the problem is readyState seems to be always 1. I am wondering if someone could perhaps give me a few moments to see if I can get this to work or suggest a better solution. I don't want to use a database approach, at least not yet. I have the following JavaScript (see below). The script requests an XML file from the server and displays it on the page. The script works fine when the requested XML file is stored on the same server as the script. The problem is when I try requesting an XML file from an external server such as the National Weather Service. I get an error. If I take the XML file from the National Weather Service and save it to my server it works. Why can't I use my script to request XML files stored on external servers? Thanks in advance for any help. Javascript Code Code: window.onload = initAll; var xhr = false; function initAll() { document.getElementById("makeTextRequest").onclick = getNewFile; document.getElementById("makeXMLRequest").onclick = getNewFile; } function getNewFile() { makeRequest(this.href); return false; } function makeRequest(url) { if (window.XMLHttpRequest) { xhr = new XMLHttpRequest(); } else { if (window.ActiveXObject) { try { xhr = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { } } } if (xhr) { xhr.onreadystatechange = showContents; xhr.open("GET", url, true); xhr.send(null); } else { document.getElementById("updateArea").innerHTML = "Sorry, but I couldn't create an XMLHttpRequest"; } } function showContents() { if (xhr.readyState == 4) { if (xhr.status == 200) { if (xhr.responseXML && xhr.responseXML.contentType=="text/xml") { var outMsg = xhr.responseXML.getElementsByTagName("choices")[0].textContent; } else { var outMsg = xhr.responseText; } } else { var outMsg = "There was a problem with the request " + xhr.status; } document.getElementById("updateArea").innerHTML = outMsg; } } HTML Code Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>My First Ajax Script</title> <script type="text/javascript" src="script01.js"></script> </head> <body> <p><a id="makeXMLRequest" href="http://www.weather.gov/xml/current_obs/KOJC.xml">Request an XML file</a></p> <div id="updateArea"> </div> </body> </html> I need help to make a Server to server connection I already have a server connected to clients, clients send msgs and it echoes back to all of them and now i want when a client sends a msg it echoes on his server and the other server too .. so when any of the clients on any of the servers sends a msg it is broadcasted all over the servers to all clients This is my SERVER code Code: import java.io.*; import java.net.*; public class MultiThreadChatServer { // Declaration section: This part to declare the server socket, client // socket, input stream // and output stream static Socket clientSocket = null; static ServerSocket serverSocket = null; // server can hold up to 10 clients static clientThread t[] = new clientThread[10]; public static void main(String args[]) { int port_number = 6000; if (args.length < 1) { System.out.println("Server Started \n" + "Now using port number=" + port_number); } else { port_number = Integer.valueOf(args[0]).intValue(); } // Initialization section: Where I try to open a server socket on the // given port try { serverSocket = new ServerSocket(port_number); } catch (IOException e) { System.out.println(e); } // Create a socket object from the ServerSocket to listen and accept // connections // Open input and output streams for this socket will be created in // client's thread since every client is served by the server in // an individual thread while (true) { try { clientSocket = serverSocket.accept(); for (int i = 0; i <= 9; i++) { if (t[i] == null) { (t[i] = new clientThread(clientSocket, t)).start(); break; } } } catch (IOException e) { System.out.println(e); } } } } // This client thread opens the input and the output streams for a particular // client, // ask the client's name, informs all the clients currently connected to the // server about the fact that a new client has joined the chat room, // and as long as it receive data, echos that data back to all other clients. // When the client leaves the chat room this thread informs also all the // clients about that and terminates. class clientThread extends Thread { DataInputStream is = null; PrintStream os = null; Socket clientSocket = null; clientThread t[]; public clientThread(Socket clientSocket, clientThread[] t) { this.clientSocket = clientSocket; this.t = t; } public void run() { String line; String name; try { is = new DataInputStream(clientSocket.getInputStream()); os = new PrintStream(clientSocket.getOutputStream()); os.println("Enter your name."); name = is.readLine(); os.println("Hello " + name + " you can now start chatting with all the connected chat-mates"); for (int i = 0; i <= 9; i++) if (t[i] != null && t[i] != this) t[i].os.println(".." + name + " has entered the chat room .."); while (true) { line = is.readLine(); if (line.startsWith("/quit")) break; for (int i = 0; i <= 9; i++) if (t[i] != null) t[i].os.println("<" + name + "> " + line); } for (int i = 0; i <= 9; i++) if (t[i] != null && t[i] != this) t[i].os.println("" + name + " has left the chat room .."); os.println("Bye " + name + " .."); // Clean up: // Set to null the current thread variable such that other client // could // be accepted by the server for (int i = 0; i <= 9; i++) if (t[i] == this) t[i] = null; // close the output stream // close the input stream // close the socket is.close(); os.close(); clientSocket.close(); } catch (IOException e) { } ; } } ok i need a bit of advice.. I have a webpage and i want to put a section of another website on to my own website.. The Section i want to put on my website is on this page www.bebo.com/thegaadiscos and i only want to put the section with the comments on it... What i want is a bit like the face book section of this website http://www.alexandraburkeofficial.com/ How would this be done does anyone know.. I'm sorry I don't have code for this one. I'm making a fansite for a game called RuneScape and I'm a bit stuck on this part. What I need for my website is, a page that will have the prices (min, middle, and max) of things from this or other items, which will be chosen later on. Here are two example sites that I am wanting to ... do the same thing as them. First Example Second Example I'd really appreciate any information you guys are willing to give. Thanks. Hello guys, Is there any way I can get the number of 'CPBucks' from this piece of HTML, It's currently at 1 but it will change. Code: <div class="user-info"> <img src="http://illiweb.com/fa/punbb/online.png" id="i_icon_online" alt="Online" title="Online"><br> <span style="white-space:nowrap;"><span style="color:##66666;">Posts</span>: </span>2<br> <span style="white-space:nowrap;"><span style="color:##66666;">CPBucks</span>: </span>1<br> <span style="white-space:nowrap;"><span style="color:##66666;">Join date</span>: </span>2011-10-11<br> </div> Thanks Can anyone let me know how can I get the href info dynamically I have 2 different webistes, just want to show those website urls dynamically <html> <body> <a href="http://www.yahoo.com" target="_blank">YAHOO</a> <a href="http://www.Google.com" target="_blank">Google</a> <script type="text/javascript"> document.write(href url of yahoo); document.write('href url of google); </script> </body> </html> thanks for help in advance I am currently working on a project that requires pretty large bits of jQuery (atleast for me) and once I get this function working I can solve more required functions but I have problems getting this to work. Basically what im trying to do is, when a link is clicked (within a certain div) it reads out the class of that link and searches within XML or JSON for the title and then finds the description within that record. I hope someone is able to point to the right direction, Thanks in advance, Mehk. Hi everyone! Firstly, im a beginner in Javascript, totally noobie. Much why this is posted! I have found this site: http://www.forswor.com/index.php/data-apis/ And I want to use this to post the server status on my forum/website. How exactly do I do that? I know there are examples and such and I have read and read on that page but I cannot figure out how to do this. I cant just paste: <script type="text/javascript" src="http://www.forswor.com/forswor_services/prod/serverwidget/getSWTORStatusjs.php"> </script> How would I get this to show the information of say for example Bloodworthy server and in text? I tried adding the line document.write(forswor_server_name);, but didnt show up anything - stupid as I am obviously I have no clue what im doing. I can manage html\css and some php but this is new for me, hehe. Thank you so much for reading an idiots post! Most regards, me. Hello everyone I would like to understand how can I do a drop down many exactly as the www.oracle.com webpage. The idea is to build some kind of menu in my web project. I know that this could be a noob question for some, thank you anyeway for any help in advanced. Renzo ++ Is it possible to get a entire system configuration information including RAM Size,Type,HD Size,Processor details using JavaScript Or any other Scripting Language. Please Help Me In Getting This. . . Hey everybody, what regular expression do i have to use to get the 2 last elements of a user agent? eg in firefox how can i get : Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20100101 Firefox/7.0.1 Firefox & 7.01 ? thanks! I'm not sure why this code executes the first if condition. What should I be doing instead? <!DOCTYPE html> <head> <style> #test { visibility:hidden; } </style> <script type="text/javascript"> function read(ID) { if(document.getElementById(ID).style.visibility == '') alert("why does this pop up?"); else if(document.getElementById(ID).style.visibility == 'hidden') alert("this is what I would expect"); else alert("never reached"); } </script> </head> <body> <form><input type="button" value="test" onclick="read('test');""> <p id='test'> testing visibility</p> </body> </html> 3D Spin Menu. cut and paste. on the page of this script, the example covers and hides the instructions and the links. I am 2 download some zip file and extract 2 files: spin.htm and spinmenu.js.But what will I do with them. [home/ free javascripts / menu and redirection / here] Just e-mail me the code. Thanks clif4688@aol.com Clif Hello all. I have a script to prompt a user for 4 pieces of information. First name. Last name Area code. & Telephone number. My assignment was to do this, and put the information is as follows. If both, first name & last name are entered, store in object as last name,first name. If only one is entered. display without the comma. Also store telephone number in (XXX) XXX-XXXX format. I was told to use methods to do all of these things. Please take note I am in a VERY basic javascript class. Thanks in advance. CODE I HAVE SO FAR : head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <script type="text/javascript"> last=name=area=num=''; function info ( ) { last = prompt("Please enter your last name",''); name = prompt("Please enter your first name",''); area = prompt("Please enter your area code",''); num = prompt("Please enter your phone number",''); }; function Person (info) { this.name = name this.last = last this.area = area this.num = num } </script> <title></title> </head> <body> <script type="text/javascript"> info ( ); teacher = new Person(); tempString=''; document.writeln ( last ); document.writeln ( name) ; if(area==''||num==''){tempString='';} else{tempString = teacher.area +''+ teacher.num} document.writeln ( tempString); </script> I'm working on a website for a freelance writer. I've used a lytebox mod to open a modal dialogue box that shows a scan of each magazine article. The code allows for an "info" button at the bottom of the window, which when clicked calls a page info.php, and populates that page with text from an [info] variable on the main page. My question is this. I'd like to use the "info" button to call entire articles in text format from a separate php page. I don't want to insert these long articles into the main page. Is there an easy way to do this in the code? The info.php page code follows: <div class="info"><?php if (isset($_GET['info'])){ $text = $_GET['info']; $text = str_replace('<br/>',"\n",$text); } else { $text = 'This page is showing text from GET "info" variable'; } echo $text; ?></div> The entire info.php page is he http://www.mimiread.com/info.php The main lytebox.js page that I'm using is he http://www.mimiread.com/lytebox.js The code line that calls this from the main page: <a href="images/ttlnob-cover.jpg" rel="lytebox[essays-ttlnob]" rev="[info]ttlnob.html[/info]" title=""><img src="images/essays-ttlnob.jpg" border="0" alt="house beautiful, the trying to leave new orleans blues" /></a> Any help would be appreciated. I have a Cisco ASA that I use as a proxy server as such. I have a internal site that it will not pass credentials to so I was looking for a way to do that. Not being a site developer the only way I can come up with is to maybe pass it by using a cookie to store the password and ID. Below is the code I am trying to use. I can create the cookie with the code below but it will not change the PATH or the Domain for some reason. Also I do not think it is reading from the cookie not sure why. Basically I need it to set the cookie with the user info and then grab the info from the cookie to auto log the user in to the internal site. <script type="text/javascript" language="JavaScript"> <!-- function writeCookie( ) { var username = document.form.username.value; // Get the user's name var password = document.form.password.value; document.cookie = "UserIDPW=" + username + "=" + password; // Create the cookie } //--> <form name="form" id="unicorn_form" method="POST" onsubmit="writeCookie()" onsubmit="disableButton()" action="/+webvpn+/index.html" onsubmit="return onSubmit();"> <td nowrap id="username_field"> <p align="right"> <span style="font-size: 8pt; font-weight: 700"> <font face="Trebuchet, arial" color="#FFFFFF"> <b>User ID:</b> </font></span></font></td> <td valign="middle"> <input class="formData" size="20" type="password" id="password_input" name="username" value=""> </td> </tr> <tr> <!-- password prompt --> <td nowrap id="password_field"> <p align="right"> <span style="font-size: 8pt; font-weight: 700"> <font face="Trebuchet, arial" color="#FFFFFF"> <b>Password:</b> </font></span></font></td> <td valign="middle"> <input class="formData" size="20" autocomplete="off" id="password_input" name="password" type="password"> </td> </tr> <tr> <td> </td> <td align="center"> <!-- "log in" button --> <input type="submit" name="Login" value="Log In" class="button"> I have a page where a user can enter info into a text box named (usertext). Below the box I have a link that takes the user to another page. This page is just a test page for proof of concept. I am wondering if there is a way that I can dynamically populate a variable located within the url of my link. The info that will populate the variable will be whatever the user types into the text box. For example my link will be <a href="nextpage.cfm?textvariable='#usertext#'> So when the user clicks this link, it goes to the next page already populated by the value of the info the user typed into the text box. I am thinking javascript will be involved, but I am not really sure. I am using coldfusion 8. This is what I have: Code: <script type="text/javascript"> $(document).ready(function(){ $('#add').click(function() { alert ('test') }); $("form#exercise").submit(function() { // we want to store the values from the form input box, then send via ajax below var activity = $('#activity').attr('value'); $.ajax({ type: "POST", url: "newActiveProc.php", data: "activity="+ activity +"&func=search", success: function(msg){ $("span#results").html(msg); } }); return false; }); }); </script> Instead of alerting the user, I want to send their choice to the a table on the same page. Does anyone have any idea of how I might do this. I've posted three threads in the ajax forum with no response. I have a form & I want the customer to be able to check a box if the bill to information is the same as the ship to information & have the information automaticlly put into the appropriate boxes. I have the following script in the head of my html page: <script language="JavaScript"> <!-- function shipsame() { var form = document.forms[0]; if(form.sameasbilling.checked){ form.shipname.value = form.shipname.value; form.shipaddress.value = form.billaddress.value; form.shipaddress2.value = form.billaddress2.value; form.shipcity.value = form.billcity.value; form.shipstate.value = form.billstate.value; form.shipzip.value = form.billzip.value; form.shipcontact.value = form.billcontact.value; form.shipphone.value = form.billphone.value; }else{ form.shipname.value = ""; form.shipaddress.value = ""; form.shipaddress2.value = ""; form.shipcity.value = ""; form.shipstate.value = ""; form.shipzip.value = ""; form.shipcontact.value = ""; form.shipbill.value = ""; } } function fixup() { var cb = document.forms[0].sameasbilling; cb.onclick = shipsame; } function MM_callJS(jsStr) { //v2.0 return eval(jsStr) } //--> </script> And I have the following in my form section: <input name="sameasbilling" type="checkbox" onclick="MM_callJS('sameasbilling')" value="yes" onload="fixup()"/> I am not a programmer & have gotten this script from searching the web. I have tried several things but do not know enough to fix the problem. I'm not even sure if the ship or bill should come first in the code. The customer will be filling out the bill to information first on my form. I would appreciate any help but please put it in VERY simple terms that I can understand. Thank you |