JavaScript - How Can I Prevent Accessing My .js File From Unwanted Sources?
My swf.js file is getting hacked along with some jquery files, they are injecting cross browser hacking script to .js files.
Please help me how can I protect it? Similar Tutorialsi m trying to extract data from an xml file and display data on Google maps but when i try to run my code In IE - Access denied error is display (while accessing the xml file) Mozilla - code is working fine but displays following error - Error: xmlDoc.getElementsByTagName("lat")[1] is undefined Source File: file:///I:/BE%20Project%20Data/coding/Myexample/exam2.html Line: 48 HTML file- <html> <head> <title>Google Maps JavaScript API v3 Example: Fusion Tables Layer</title> <link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" /> <style type="text/css"> html { height: 100% } body { height: 100%; margin: 0px; padding: 0px } #map_canvas { height: 500px;width: 800px } </style> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> function initialize() { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET","agridata.xml",false); xmlhttp.send(); xmlDoc=xmlhttp.responseXML; var latlng = new google.maps.LatLng(48.75028,-94.91667); var mapOpts = { zoom: 5, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP, }; var map = new google.maps.Map(document.getElementById("map_canvas"),mapOpts); var l1=xmlDoc.getElementsByTagName("lat")[1].childNodes[0].nodeValue; var l2=xmlDoc.getElementsByTagName("lng")[1].childNodes[0].nodeValue; var pt = new google.maps.LatLng(parseFloat(l1), parseFloat(l2)); var marker = new google.maps.Marker({ position: pt, map: map, title: 'Just a simple marker'}); } </script> </head> <body onload="initialize();"> <h1>output</h1> <div id="map_canvas"></div> </body> </html> XML file - <?xml version="1.0"?> <markers> <marker> <lat>52.09667</lat> <lng>-173.50056</lng> <state>Alaska</state> <county>Aleutian</county> </marker> <marker> <lat>48.75028</lat> <lng>-94.91667</lng> <state>Minnesota</state> <county>Lake of woods</county> </marker> <marker> <lat>52.09667</lat> <lng>-173.50056</lng> <state>Washington</state> <county>Stevans</county> </marker> </markers> do let me know the reason behind the undefined error and ACCESS DENIED error ... i have tried modification in the security setting of the browser but error is not solved yet ... thks OK, There's a script on my site that's included like <script src='somePHPfile.php?params... etc It generates an image with some text in it and a few links. When I click 'view source' it just comes up with the <script> tags and nothing else. In Firefox, if I right click on the actual image and go to this frame > view source, I can see everything it's doing. Is there some way I can access this code with Javascript/jquery? I've tried html/dom parsers, etc. with no luck. Hi I have a large'ish project under development. The code below distills the problem I am having. In essence, I am trying to read in an XML file. It appears to load okay but when I try to count how many there are of a certain tag (The "Team" tag) I am told that there are zero. This is despite being told that that file loads okay (as the callback function is called). Javascript and the xml file is below. I hope that it is easy to follow. When the page is loaded, the initialize function is called. I first check my browser as I only need this to work on a Mozilla browser (I am using Mozilla Firefox 3.6.3). I then load the xml file and the callback function (fileLoaded) is called. I then try to find out how many "Team" tags I have, but get the message that there are zero. Sorry if this is a simple question but I have spent the best part of yesterday trying to get this to work. Any help would be appreciated. Thx G === javascript === 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" xml:lang="en" lang="en"> <head> <script type="text/javascript"> // Global variable so that everything can access it var xlmDoc; function initialize() { // This function gets called when the page loadds browserCheck(); xmlDoc=document.implementation.createDocument("", "doc", null) xmlDoc.load("small.xml"); // This file is shown at the end of this document, but it is a separate xml document xmlDoc.onload = fileLoaded; } // End of initialize function fileLoaded() { // Called when file is loaded (this does get called as expected) alert("File loaded"); var teams = xmlDoc.getElementsByTagName("Team"); var count = teams.length; alert("no of Teams: " + count); // This displays zero - WHY??? } // End of fileLoaded function browserCheck() { // START: This function just checks that I am using a Mozilla browser (I am) var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined'); if(moz) { alert("Mozilla"); } else {alert("Not Mozilla"); } } // End of browserCheck </script> </head> <body onload="initialize()"> </body> </html> === xml file === Code: <Root> <Team> <Type>GLF</Type> <Name>Verulam</Name> <Postcode>AL1 1JG</Postcode> <Page>693</Page> </Team> <Team> <Type>RFU</Type> <Name>London Manx RFC</Name> <Postcode>AL1 2DJ</Postcode> <Page>704</Page> </Team> <Team> <Type>RFU</Type> <Name>University of Hertfordshire RFC</Name> <Postcode>AL10 9AB</Postcode> <Page>729</Page> </Team> </Root> Could you please help me with this. I've tried multiple ways of doing this, but nothing works. Code: <html> <head> <style> table { background: lightblue; padding: 30px; margin: 20px; } .border{ text-align: center; border: thin solid black; padding: 40px; font-size: 50px; } img { border:1px solid black; } .vis { padding: 40px; border: thick solid black; text-align: center; border-spacing: 30px; background: maroon; } .invis { background: lightblue; } </style> <script type="javascript/text"> var item = document.getElementById('animal'); function change(name){ item.src = name; } function back(){ item.src = "blank.jpg"; } function changeName(word){ var item2 = document.getElementById('animalName') item2.innerHTML = word } </script> </head> <body> <table width="700" height="600" cellspacing="40"> <tr> <td class="vis" rowspan="3"><p><br> <img src="cat.thumb.jpg" onMouseOver="change('cat.jpg'); changeName('cat')" onMouseOut="back();"> <p> <img src="dog.thumb.jpg" onMouseOver="change('dog.jpg'); changeName('dog')" onMouseOut="back();"> <p> <img src="cow.thumb.jpg" onMouseOver="change('cow.jpg'); changeName('cow')" onMouseOut="back();"> <p> <img src="owl.thumb.jpg" onMouseOver="change('owl.jpg'); changeName('owl')" onMouseOut="back();"> <p> <img src="pig.thumb.jpg" onMouseOver="change('pig.jpg'); changeName('pig')" onMouseOut="back();"> <p> </td> <td class="invis"> </td></tr> <tr> <td class="vis"> <div class="border"> <h1 id='animalName'>Dog</h1> </div> <br> <img id='animal' src="blank.jpg"> </td> </tr> <td class="invis"> </tr> </table> </body> </html> I've been looking around and haven't been able to find much on the subject. Anyways I'm wondering how to pull data from more than one xml source on a single page. I've found people referencing the subject but nothing concrete on how it's done. Any help would be much appreciated.
I'm attempting to run a small piece of code that will execute one of two source js files on my server. I have no problem creating the proper DOM script object with the proper type and conditional src value. However, when i add it to the document it does not seem to execute. I've tried adding it in two places, both using .appendChild(); myLocation.parentNode.appendChild(newScript); and document.getElementsByTagName("head")[0].appendChild(newScript); (myLocation is a calculated element representing the current script tag) In both these cases, the script tag is added to the document where I intended, but it does not appear to execute. The src has some doc writes in it and the tags the new script should generate right after itself are not there, as they are when I hard code the new sourced script tag into the document. All in all, my confusion comes from the fact that when I write a <script ... src="mysrc.js"></script> into my document, it behaves differently than when I have a script write an identical tag into the document in the same location. Also, fyi, I'm currently using Chrome (though I will require a multi-platform solution). Thanks for your time. I am wondering if there is a way to display feeds from multiple sources on my page using this tool. The feeds are at the following URL http://www.vanityasart.com/viastorm.com/news.html It loads the first feed fine and then stops loading the others. Any ideas? H Hello all, I need my form to submit to two sources, zoho crm and broker office. One is used to create a contact list and the other is an insurance quote engine. Problem one. How can I use javascript to force my form to submit data to both sites? The bigger problem is they use different names for the same field. In other words one wants to recieve a vaule as first_name and the other wants it as firstName. Thanks in advance. hy all, I am creating an accordion menu that when i press the " UNIT " tab, it opens up a list of " Chapters " tab, and when i press on any one of those chapters, a list of lessons opens up. Till now, i have managed to create all the appropriate lists, but in default, lessons and chapters are opened automatically, and the lessons elements when pressed do not scroll back up to the chapters parents. My html5 file: Code: <script type="text/javascript" src="jqueryjs.js"></script> <script type="text/javascript" src="jqueryuiaccor.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#accordion').accordion(); }); </script> <div id="container"> <div id="content"> <div id="sidebar"> <ul id="accordion"> <li> <a href="#recent" class="heading">Unit 1</a> <ul id="accordion"> <li> <a href="#recent" class="heading">Chapter 1 </a> </li> <ul id="accordion2"> <li> Lesson 1 </li> </ul> </ul> </li> <li> <a href="#recent" class="heading">Unit 2</a> <ul id="accordion"> <li> <a href="#recent" class="heading">Chapter 1 </a> </li> <ul id="accordion"> <li> <a href="#recent" class="heading" role="tab" aria-expanded="true">Chapter 2 </a> <ul id="accordion"> <li> <a href="#recent" class="heading">Lesson 1 </a></li> </ul> </li> </ul> </ul> </li> </ul> </div> </div> </div> My acorjs.js file: Code: $(document).ready(function() { $('ul#accordion a.heading').click(function() { $(this).css('outline','none'); if($(this).parent().hasClass('current')) { $(this).siblings('ul').slideUp('slow',function() { $(this).parent().removeClass('current'); $.scrollTo('#accordion',1000); }); } else { $('ul#accordion li.current ul').slideUp('slow',function() { $(this).parent().removeClass('current'); }); $(this).siblings('ul').slideToggle('slow',function() { $(this).parent().toggleClass('current'); }); $.scrollTo('#accordion',1000); } return false; }); }); Please HELP! Hello, I have a multi-dimensional object, derived from JSON returned by the Foursquare API. The object has the following structure (as printed using a print_r type method from http://www.openjs.com/scripts/others...hp_print_r.php PHP Code: '0' 'id' => "27110xxx" 'created' => "Sun, 11 Apr 10 15:09:45 +0000" 'timezone' => "America/New_York" 'user' ... 'id' => "48xxx" 'firstname' => "Barry" 'lastname' => "xxx" 'photo' => "http://playfoursquare.s3.amazonaws.com/userpix_thumbs/4abb5bxxxxxx.jpg" 'gender' => "male" 'display' => "xxxx. @ [off the grid]" '1' ... 'id' => "2538xxxx" 'created' => "Wed, 07 Apr 10 13:24:41 +0000" 'timezone' => "Europe/London" Could anyone tell me the best way to access its elements? I have this so far which gets the required values, but I want to preserve the order ie. get the data from the first element in the object first, then move to the next - each element represents a user so I want to keep their data separate. PHP Code: /* This is a custom function which has the same function as print_r */ function dump(arr,level) { var firstName, lastname, geolat, geolong, photo; var dumped_text = ""; if(!level) level = 0; //The padding given at the beginning of the line. var level_padding = " "; for(var j = 0; j < level + 1; j++) level_padding += " "; if(typeof(arr) == 'object') { //Array/Hashes/Objects for(var item in arr) { var value = arr[item]; if(typeof(value) == 'object') { //If it is an array, dumped_text += level_padding + "'" + item + "'\n"; dumped_text += dump(value,level + 1); } else { dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n"; } if (item == 'firstname') { firstname = value; document.write("First name: " + firstname + "<br />"); document.write(item); } if (item == 'lastname') { lastname = value; document.write("Last name: " + lastname + "<br />"); document.write(item); } if (item == 'geolat') { geolat = value; document.write("Latitude: " + geolat + "<br />"); document.write(item); } if (item == 'geolong') { geolong = value; document.write("Longitude: " + geolong + "<br />"); document.write(item); } } } else { //Stings/Chars/Numbers etc. dumped_text = "===>"+arr+"<===("+typeof(arr)+")"; } return dumped_text; } var myObj = <?php echo json_encode($checkin); ?>; alert(dump(myObj)); Sorry for the bloated code, I normally work in Java and PHP so although I understand the theory, I haven't worked with objects much in JavaScript before. Any help would be much appreciated! Hi all, I made up a little test program to grab the mouse X and Y coordinates and plan to use it to allow users to resize a window. Anyway, the problem I'm having is that in MSIE-8, the mouse down and movement causes text to be selected (which I don't want). Here's is a screenshot from MSIE: And here is the test program live online: http://three-dog.homelinux.com/mouse/index.htm Notice that the text in the box is selected ... I don't want that to happen. Of course, it works just fine in Firefox, but not MSIE. I would appreciate if someone can tell me how to fix this (and if possible look at my code and see if I'm doing it right - I'm not very skilled at events yet). Thank you. -- Roger Scroll down to the bottom. Click on an "X" button to bring up a DHTML popup. Select an item. When the DHTML closes and the original HTML is updated the browser scrolls to top. Is there a way to stop this by wrapping it somehow in a container, since you can't stop the scroll event?
Code: <html> <head> <title> Vendor Management</title> </head> <body> <table border="0" width="100%"> <tr> <td></td> <td></td> <td></td> </tr> <tr> <td colspan="2" align="left" valign="top"> <img src=""/> </td> <td><img src=""/></td> </tr> <tr> <td align="left" valign="top"> <a href=""/></a> <a href=""/></a> <a href=""/></a> </td> <td align="left"> <img src=""/> </td> <td> <img src=""/> </td> </tr> <tr> <td> <span class="pageHeading" align="left"> Web Administrator </span> </td> </tr> </table> <br/> <form name="form" method="post" action=""> <table width="100%"> <tr> <td width="5%"></td> <td align="left"> <p class="filter"> All<br/> All<br/> </p> </td> <td> <table width="40%" border="1" > <tr> <td class="h" colspan="2">Color Key </td> </tr> <tr> <td class="S "> </td><td class="small">The is being negotiated. The administrator may finalize the when it is complete.</td> </tr> <tr> <td class="SAVA">Awaiting Vendor Approval </td><td class="small">The has been finalized and is waiting for the Vendor to sign it.</td> </tr> <tr> <td class="SLocked">Locked</td><td class="small">The has been finalized and signed. All the Locked items in the will be in the show.</td> </tr> </table> </td> </tr> <tr> <td colspan="3"> <table align="center"> <tr> <td>Search:</td> <td> <input name="searchValue" id = "searchValue" type="text" size="24" value=""> </td> <td> By </td> <td> <select name="searchColumn" id="searchColumn"> <option value="VENDOR_NAME" SELECTED> Vendor Name</option> <option value="VENDOR_NUMBER" > Vendor Number</option> </select> </td> <td> And </td> <td> <select name="searchQualifier" id="searchQualifier"> <option value="CONTAINS" SELECTED>Contains</option> <option value="STARTS_WITH" >Starts With</option> <option value="ENDS_WITH" >Ends With</option> </select> </td> <td> <input type="button" name="SearchButton" id="SearchButton" value="Search" onClick="onVendorSearch()"> </td> <td> <input type="button" name="ClearSearchButton" id="ClearSearchButton" value="Clear" onClick="onVendorClear()"> </td> </tr> </table> </td> </table> <table width="90%" align="center" > <tr align="center"> <td colspan="3"> <br> <input name="reference" type="hidden" value="viewVendorUsersCheck"> <input name="action" type="hidden" value="delete"> </td> </tr> </table> <table id="results" width="100%" border="1" style="border-color:black" align="left"> <!-- START OF DATA --> <tr class="S "> <td> <a name="">005890</a></td> <td> Ivy-Dry, Inc</td> <td> </td> <td> </td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_005890" name="vendorBooth_005890" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_005890" id="vendorBoothBtn_005890" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td> <a href=""> </a> </td> <td>8</td> <td>0</td> <td>0</td> <td></td> <td>20141</td> <td></td> <td></td> <td></td> </tr> <tr class="S "> <td> <a name="006867">006867</a></td> <td> Pacific World Corporation</td> <td> </td> <td> </td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_006867" name="vendorBooth_006867" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_006867" id="vendorBoothBtn_006867" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td>0</td> <td>0</td> <td>0</td> <td></td> <td>20154</td> <td></td> <td></td> <td></td> </tr> <tr class="S "> <td> <a name="">006952</a></td> <td> Prince Of Peace Enterprises</td> <td></td> <td></td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_006952" name="vendorBooth_006952" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_006952" id="vendorBoothBtn_006952" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td>0</td> <td>0</td> <td>0</td> <td></td> <td>20155</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr class="S "> <td> <a name="">006996</a></td> <td> Bayer , Division</td> <td></td> <td></td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_006996" name="vendorBooth_006996" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_006996" id="vendorBoothBtn_006996" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td>21</td> <td>0</td> <td>0</td> <td></td> <td>20156</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr class="S "> <td> <a name="">007003</a></td> <td> Kerr Group, Inc. / Kerr </td> <td></td> <td></td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_007003" name="vendorBooth_007003" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_007003" id="vendorBoothBtn_007003" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td>92</td> <td>0</td> <td>0</td> <td></td> <td>20157</td> <td></td> <td></td> <td></td> </tr> <tr class="S "> <td> <a name="">007010</a></td> <td> Unilever</td> <td></td> <td></td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_007010" name="vendorBooth_007010" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_007010" id="vendorBoothBtn_007010" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td>160</td> <td>0</td> <td>0</td> <td></td> <td>20158</td> <td></td> <td></td> <td></td> </tr> <tr class="S "> <td> <a name="">007057</a></td> <td> Pfizer </td> <td></td> <td></td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_007057" name="vendorBooth_007057" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_007057" id="vendorBoothBtn_007057" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td>9</td> <td>0</td> <td>0</td> <td></td> <td>20159</td> <td></td> <td></td> <td></td> </tr> <tr class="S "> <td> <a name="">007060</a></td> <td> Johnson & </td> <td></td> <td></td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_007060" name="vendorBooth_007060" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_007060" id="vendorBoothBtn_007060" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td>71</td> <td>0</td> <td>0</td> <td></td> <td>20160</td> <td></td> <td></td> <td></td> </tr> <tr class="S "> <td> <a name="">007112</a></td> <td> Colgate-Palmolive </td> <td></td> <td></td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_007112" name="vendorBooth_007112" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_007112" id="vendorBoothBtn_007112" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td>39</td> <td>0</td> <td>0</td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr class="S "> <td> <a name="">007120</a></td> <td> W.F. Young, </td> <td></td> <td></td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_007120" name="vendorBooth_007120" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_007120" id="vendorBoothBtn_007120" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td>0</td> <td>0</td> <td>0</td> <td></td> <td>20162</td> <td></td> <td></td> <td></td> </tr> <tr class="S "> <td> <a name="">007120</a></td> <td> W.F. Young, </td> <td></td> <td></td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_007120" name="vendorBooth_007120" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_007120" id="vendorBoothBtn_007120" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td> <a href=""> </a> </td> <td>0</td> <td>0</td> <td>0</td> <td></td> <td>20162</td> <td></td> <td></td> <td></td> </tr> <tr class="S "> <td> <a name="">007120</a></td> <td> W.F. Young, </td> <td></td> <td></td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_007120" name="vendorBooth_007120" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_007120" id="vendorBoothBtn_007120" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td>0</td> <td>0</td> <td>0</td> <td></td> <td>20162</td> <td></td> <td></td> <td></td> </tr> <tr class="S "> <td> <a name="">007120</a></td> <td> W.F. Young, </td> <td></td> <td></td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_007120" name="vendorBooth_007120" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_007120" id="vendorBoothBtn_007120" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td> </td> <td>0</td> <td>0</td> <td>0</td> <td></td> <td></td> <td> </td> <td> </td> <td> </td> <td></td> </tr> <tr class="S "> <td> <a name="">007167</a></td> <td> 3M </td> <td></td> <td></td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_007167" name="vendorBooth_007167" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_007167" id="vendorBoothBtn_007167" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td>0</td> <td>0</td> <td>0</td> <td></td> <td>20163</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr class="S "> <td> <a name="008877">008877</a></td> <td> x Brands</td> <td></td> <td></td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_008877" name="vendorBooth_008877" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_008877" id="vendorBoothBtn_008877" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td>3</td> <td>0</td> <td>0</td> <td></td> <td>20168</td> <td></td> <td></td> <td></td> </tr> <tr align="center" bgcolor="9999FF" class="e"> <td></td> </tr> <tr bgcolor="9999FF" class="h"> <td colspan="11" class="h"> Vendor Users and s: </td> <td class="h" align="center"><input type="submit" name="Submit" value="Submit"></td> <td colspan="4" class="h"></td> </tr> </table> <script type="text/javascript"> window.onload = function () { DCCinitPage(); }; function DCCinitPage() { var IE = document.all?true:false; if (!IE) document.captureEvents(Event.MOUSEDOWN); document.onmousedown = DCCmousePosition; } function DCCmousePosition(e) { var IE = document.all?true:false; var tempX = 0; var tempY = 0; if (IE) { tempX = event.clientX + document.body.scrollLeft; tempY = event.clientY + document.body.scrollTop; } else { tempX = e.pageX; tempY = e.pageY; } if (tempX < 0){tempX = 0;} if (tempY < 0){tempY = 0;} DCCmouse.setLeft(tempX); DCCmouse.setTop(tempY); return true; } function DCCmouseClass() { this.left = 0; this.top = 0; this.setLeft = function (left) { this.left = left; } this.getLeft = function() { return this.left; } this.setTop = function (top) { this.top = top; } this.getTop = function() { return this.top; } } var DCCmouse = new DCCmouseClass(); function DCCshowBoothList(thisId) { var indexOfNumber = thisId.indexOf("vendorBoothBtn_"); var thisNumber = thisId.substring(indexOfNumber + 15); document.forms[0].tempVendorNumber.value = thisNumber; document.getElementById("DCCboothList").style.top = (DCCgetWindowTop() + 20) + "px"; document.getElementById("DCCboothList").style.left = (DCCmouse.getLeft() + 15) + "px"; document.getElementById("DCCboothList").style.display=""; } function DCCcloseBoothList() { document.getElementById("DCCboothList").style.display="none"; } function DCCboothSelected(boothId) { document.getElementById("DCCboothList").style.display="none"; var indexOfNumber = boothId.indexOf("boothNumber_"); var indexOfIndex = boothId.indexOf("index_"); var indexOfName = boothId.indexOf("name_"); var boothNumber = boothId.substring(indexOfNumber + 12, indexOfIndex); var boothIndex = boothId.substring(indexOfIndex + 6, indexOfName); var boothName = boothId.substring(indexOfName + 5); var vendorNumber = document.getElementById("tempVendorNumber").value; var displayBoothNumber = "vendorBooth_" + vendorNumber; document.getElementById(displayBoothNumber).value = boothNumber; document.getElementById(displayBoothNumber).name = displayBoothNumber + "_dirty"; document.getElementById(displayBoothNumber).title = boothName; } function DCCgetWindowTop() { var winTop = 0; if( typeof( window.pageYOffset ) == 'number' ) { winTop = window.pageYOffset; } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { winTop = document.body.scrollTop; } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) { winTop = document.documentElement.scrollTop; } return winTop; } function DCCgetWindowLeft() { var winLeft = 0; if( typeof( window.pageXOffset ) == 'number' ) { winLeft = window.pageXOffset; } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { winLeft = document.body.scrollLeft; } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) { winLeft = document.documentElement.scrollLeft; } return winLeft; } </script> <style> .DCChiglightHover:hover { background-color: rgb(200,200,200); } </style> <div id="DCCboothList" style=" position: absolute; top: 200px; left: 350px; height: 360px; width: 300px; background-image: url(/DCC5/pages/shared/images/transp.gif); display: none; "> <input type="hidden" name="tempVendorNumber" id="tempVendorNumber" value="" /> <p align="right" style="padding: 0; margin: 0;"> <input style="height: 18px; width: 20px; background-image: url(dummy.gif); border-top: 1px solid rgb(210,210,210); border-left: 1px solid rgb(210,210,210); border-right: 1px solid rgb(210,210,210); border-top: 0px solid rgb(210,210,210); color: rgb(210,0,0);" type="button" id="closeBoothList" name="closeBoothList" value ="X" onclick="DCCcloseBoothList()" /> </p> <div id="DCCboothListInner" style="background: rgb(240,240,240); border: 1px solid rgb(130,130,130); height: 334px; overflow: auto; "> <p style="padding: 0; margin: 0"> <a href="" class="DCChiglightHover" id="boothNumber_D010index_0name_Beef Booth" style="text-decoration: none; color: black;" onclick="DCCboothSelected(this.id)">D010Beef Booth</a> </p> <p style="padding: 0; margin: 0"> <a href="" class="DCChiglightHover" id="boothNumber_D006index_1name_DCC Test Booth D006" style="text-decoration: none; color: black;" onclick="DCCboothSelected(this.id)">D006DCC Test Booth D006</a> </p> <p style="padding: 0; margin: 0"> <a href="" class="DCChiglightHover" id="boothNumber_D005index_2name_DCC Test Booth D005" style="text-decoration: none; color: black;" onclick="DCCboothSelected(this.id)">D005DCC Test Booth D005</a> </p> <p style="padding: 0; margin: 0"> <a href="" class="DCChiglightHover" id="boothNumber_D004index_3name_DCC Test Booth D004" style="text-decoration: none; color: black;" onclick="DCCboothSelected(this.id)">D004DCC Test Booth D004</a> </p> <p style="padding: 0; margin: 0"> <a href="" class="DCChiglightHover" id="boothNumber_269index_92name_ARCHTECH" style="text-decoration: none; color: black;" onclick="DCCboothSelected(this.id)">269ARCHTECH</a> </p> </div> </div> <!-- End code for custom booth list drop down --> </form> </body> </html> NOTE: If you are tempted to respond "validate your code" or some other useless response, save your breath. This is a real world problem. The code is an fragment output from a JSP. I don't have the luxury of updating 2000 jsp files to make it up to standard. i have this code: PHP Code: <?php foreach ($freechat_list as $r) { $uniqueCode = substr($r,0,12); $id = substr($r,13); $blocked_record = RcBlockListTablePeer::isBlocked($id,$requestor_id); ?> <a href="#" id="profilelink" name="profilelink" onClick="return viewornot(<?php echo $id."/".$blocked_record; ?>)"><?php echo $uniqueCode; ?></a> } then i have my JS: [CODE] thank you all but i am totally confused now...here is my full code: <?php foreach ($freechat_list as $r) { $uniqueCode = substr($r,0,12); $id = substr($r,13); $blocked_record = RcBlockListTablePeer::isBlocked($id,$requestor_id); ?> <a href="#" id="profilelink" name="profilelink" onClick="return viewornot(<?php echo $id."/".$blocked_record; ?>)"><?php echo $uniqueCode; ?></a> } my JS: Code: function viewornot(id) { alert(id); } alert(id) only gives me the id but in my href i concatenated it with blocked_record: viewornot(<?php echo $id."/".$blocked_record; ?>) please help? I'm trying to accessing the Parent window fom a sub window previously opened using window.open I'm using firebug to t yand debug, and it shows that this DOM entry exists.. window.opener.location.href But trying to access it gives "window opener is null" error I've tried all these, and get the various errors tagged on the end... Code: <script language="JavaScript"> //alert(opener.location); // = opener is null //alert(opener.location.href); // = opener is null //alert(parent.location); // = uncaught exeption - could not convert to javascript argument arg 0 //alert(parent.location.href); // = Permission denied to get property Location.href //alert(parent.opener.location); // = uncaught exeption - could not convert to javascript argument arg 0 //alert(parent.opener.location.href); // = Permission denied to get property Location.href //alert(parent.window.opener.location.href); // = Permission denied to get property Location.href //alert(parent.window.opener.location.href); // = Permission denied to get property Location.href //alert(window.opener.location); // = window opener is null //alert(window.opener.location.href); // = window opener is null //alert(window.parent.location); // = uncaught exeption - could not convert to javascript argument arg 0 </script> driving me crazy! Anyone have a solution? Hey is it possible to access javascript variables in an iframe src page from the parent page, or vice versa. How do you do this? What about the DOM? thanks I have developped a script in order to resize the height of a div on a web page in order to display it at least up to the size of the window. Here is the code: function resize(){ var frame = document.getElementById("content"); var padding_top = parseInt(window.getComputedStyle(frame,null).getPropertyValue("padding-top")); var padding_bottom = parseInt(window.getComputedStyle(frame,null).getPropertyValue("padding-bottom")); var padding = padding_top + padding_bottom; var bodyheight = document.body.scrollHeight; var windowheight = window.innerHeight; if (bodyheight < windowheight){ frame.style.height = windowheight - padding + "px"; } } It works well, but I was wondering why I am not able to get the padding-top and -bottom using these two instructions: var padding_top = frame.style.paddingTop; var padding_bottom = frame.style.paddingBottom; The script runs but Firebug shows empty strings for both values. How come? Is there a bug in Firefox? Thanks inadvance for your time and help. What i have is a system where the amount of HTML lines is generated by php when the page loads. Each time has exactly the same set up except there names have an int added to them in accending order. What i need is for them to pass a variable to the javascript function telling them what number they are, and the javascript then using this to access it to read and change information. Is the line below correct for this task? Code: document.Purchase.(Tax+i).selectedIndex; Hello, I am working on a project using HTML and javascript to allow the user to choose a vehicle from a drop down menu, then load a new page showing some information about this vehicle. The information is stored in an Excel file. I posted regarding this issue a while back and got an excellent response from Old Pedant (thanks again!) about using ActiveX - which has thus far worked perfectly. My initial condition was that I would only be using IE7+. However, my next idea was to be able to use it on an IPad (which I unfortunately do not own yet, making any kind of testing difficult) which I am fairly certain ActiveX won't work on. So, I was looking for any other method which would be similar. Important note: this will not use the internet at all, all of these files will be available locally. There is a lot of material on running queries to servers, but I didn't think that would really apply here. It seems pretty clear that JS has difficulty accessing files client side (which I understand why completely), but I was hoping to find something that worked for the gray zone I'm currently working in since I'm not using servers at all. I know that this is not really the intended use of HTML/JS, but I was hoping that by writing it as an HTML file, it'd be accessible to anyone with a browser. Some of my target computers have odd limitations (such as not being to download .exe files). The code I based my original off of is shown below: Code: <script type="text/javascript"> var conn = new ActiveXObject("ADODB.Connection") conn.Open ( 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\full\path\to\MyExcel.xls;Extended Properties="Excel 8.0;HDR=Yes;IMEX=1";)'; var sql = "SELECT * FROM [nameOfSheet$]"; var rs = conn.execute( sql ) while ( ! rs.eof ) { // just an example of dumping everything from the sheet out to the browser: for ( var f = 0; f < rs.fields.count; ++f ) { document.write( rs.fields(f).value + "," ); } document.write("<br>\n"); rs.moveNext(); } rs.close(); conn.close(); </script><script type="text/javascript"> var conn = new ActiveXObject("ADODB.Connection") conn.Open ( 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\full\path\to\MyExcel.xls;Extended Properties="Excel 8.0;HDR=Yes;IMEX=1";)'; var sql = "SELECT * FROM [nameOfSheet$]"; var rs = conn.execute( sql ) while ( ! rs.eof ) { // just an example of dumping everything from the sheet out to the browser: for ( var f = 0; f < rs.fields.count; ++f ) { document.write( rs.fields(f).value + "," ); } document.write("<br>\n"); rs.moveNext(); } rs.close(); conn.close(); </script> Thank you, klarosa Hello, I have a simple form with simple validation. I am just playing around a bit with forms and don't really have concrete knowledge. What I have done is created a form. Asking for first name, last name, age and email. When the user clicks the submit button I want 2 functions to run, the first checking the input is correct and also making sure all fields have a value. Once everything is checked and is O.K I want to go into another function which sends all this information to an array one by one. I am having difficulty accessing each individual input tag. I could achieve what I want to do, but it will take double the lines of code because each input has a different 'name'. So, what I am trying to do is access the input tags the same as you would do an array. Here is my code: HTML: Code: <form name="regForm" id="form"> <fieldset> <legend>Real Heroes - Registration Form</legend> <p>First Name:<input type="text" size="30" maxlength="20" name="txtFirstName" /></p> <p>Last Name:<input type="text" size="30" maxlength="20" name="txtLastName" /></p> <p>Age:<input type="text" size="30" maxlength="3" name="txtAge" /></p> <p>Email Address:<input type="text" size="30" maxlength="50" name="email" /></p> <p><input type="button" value="Submit Registration" name="butChkForm" onclick="callFuncs_onclick()" /> <input type="reset" value="Reset" name="resetForm" /></p> </fieldset> </form> JavaScript: Code: //CALLING THE FORM SCRIPTS// function callFuncs_onclick() { chkForm_onclick(); creatingDatabase_onclick(); } //**************FORM VALIDATION***************// function chkForm_onclick() { var theForm = document.regForm; if (theForm.txtFirstName.value == "" || theForm.txtLastName.value == "" || theForm.txtAge.value == "" || theForm.email.value == "") { alert("Please complete all of the form."); if (theForm.txtFirstName.value == "") { theForm.txtFirstName.focus(); } if (theForm.txtLastName.value == "") { theForm.txtLastName.focus(); } if (theForm.txtAge.value == "") { theForm.txtAge.focus(); } if (theForm.email.value == "") { theForm.email.focus(); } } else if (isNaN(theForm.txtAge.value)) { alert("That is not valid input for this field. Please re-enter your age."); theForm.txtAge.focus(); } else { alert("Thank you for completing the form, " + theForm.txtFirstName.value); } } function creatingDatabase_onclick() { var form = document.regForm; var index = form.input[0].value; alert(index); } I'm not quite sure where I am going wrong. Please note that these functions really labour the point, I know I have way too many lines of code but I am still very amateur with JS. Thank you for any help/information. Kind Regards, LC. I created an array, whose entries looks like this: [41, "The bird flew into it's cage"] [33, "He drew fire from Joe"] [33, "Roger asked her her name"] [2, "I am awfully happy"] . I want to pull the sentence item out of some array entries. E.g., in the second entry, namely, arrayName[1], what I thought was the second item (the sentence), I could manage by invoking arrayName[1][1] . But to my dismay, this doesn't do the trick. arrayName[1][1] actually delivers up the second CHARACTER of the entry (the number "3"). I thought the comma between the number and the sentence would separate the items, although I "pushed" each entry into the array as one single entry. How do I "grab" the whole sentence? How do I push both items separately to achieve "one entry"? |