JavaScript - Testing/discussion About Js Obfuscation
Hello,
JavaScript Obfuscation is always a topic which generates some controversy. Its use has many pros and cons depending on what one wishes to achieve. We have extensive knowledge about the subject and we would like to encourage a open discussion on the topic of JavaScript obfuscation: Techniques, application cases, ... Why are we interested in talking openly about this? Well, we are developing a new tool for javascript obfuscation which is still in beta and would like to improve it based on you feedback. If you wish you can check it out at: www.jscrambler.com. Thanks Similar TutorialsHi, so, I had a rethink about my problem discussed in this thread, where the function won't run properly a second time if the page hasn't been reloaded. That one appears not to have a solution, and I was thinking that a reasonable plan B is the following: a) test if the function has already been run since the page was loaded b) if not, run the function c) if it has, reload the page with the onClick, then run the function automatically on reloading. the problem I envisage is will the page "remember" to run the function once it has been reloaded? Of course, it would be simpler to do it running the function automatically once the page loads, then just reloading if the test comes back that the function has been run already, but that wouldn't work for the first time you visit the page - it would start running straight away, whereas I want it to wait for that first click. Is this possible? Here's the page I'm working on, if you want to have a look. thanks for any suggestions. I have a script that I had written for me that works in IE (I guess its a ActiveX?) but I display it in the HTML page as the below HTML. I want to be able to tell in Javascript if this object is available in IE Code: <object id="IEPrinterChecker" classid="CLSID:506974F1-EA53-40C6-940A-4A1D47D5934B" width="0" height="0"></object> Listed below you can tell I can check if the plugin is available in Firefox without having to specify in the html the object. How can I do this in IE? Code: <script language="JavaScript"> var plugin; if ( window.ActiveXObject ) { // IE alert("How do I check for the plugin here?"); } else { var type = "application/printer-checker-component;version=1.0.0.1"; // your mimeType if (navigator && navigator.mimeTypes){ var mt = navigator.mimeTypes; for (var i = 0; i < mt.length; i++){ if (mt[i].type == type) { plugin = mt[i].enabledPlugin; if (plugin) break; } } } } if(plugin) { // insert object and/or test the plugin with script alert("plugin is available"); } else { alert("plugin not available or disabled"); } </script> Hi, The following code tests the 'numbers' field for numbers. It generates an alert if the field contains anything but numbers. Code: <script type='text/javascript'> function isNumeric(elem, helperMsg){ var numericExpression = /^[0-9]+$/; if(elem.value.match(numericExpression)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } } </script> <form> Numbers Only: <input type='text' id='numbers'/> <input type='button' onclick="isNumeric(document.getElementById('numbers'), 'Numbers Only Please')" value='Check Field' /> </form> However, if I want to change the above statement to read if the textfield does not equal to a number, return true, else, alert the user and return false. I change the branch statement and have it read "if(!(elem.value.match(numericExpression)))," to try to do this. But, the alert message does not generate if I enter "abc123" even though that value clearly contains numbers. Not sure what is going here. Please help me. Thank you. Hi, So I'm testing my webpage in IE8. In firefox it looks and runs greag, but in IE 8, one issue I'm having is this: I have a button that opens a popup window. Works fine in Firefox, but I get 'invalid argument' error in IE8 and the window does not open. I've enabled at a whim some scripting things in the Internet Options hoping that would resolve the issue, but not so. Here's the code. The "invalid argument" occurs on the window.open call. Code: function open_report() { createURL(); var report_vars = created_URL; report_vars = report_vars.substr(69); report_array = report_vars.split('='); var from_d = report_array[2].substr(0,10); var to_d = report_array[3].substr(0,10); window.open('detailedreport.shtml' + report_vars, 'My Site | Detailed Report - ' + from_d + ' to ' + to_d, 'title=yes, status=no, toolbar=no, location=no, menubar=no, scrollbars=yes, modal=yes, alwaysRaised=yes, width=' + window.outerWidth / 1.1 + ', height=' + window.outerHeight); } In addition, is there any way to have that tile I've given it, "my Site..." appear in the window header? Right now it's not appearing at all in either browser. Thanks for reading! Why is this happening? Code: var pattern = /^\s+|\s+$/g; var string = " spaces"; while(pattern.test(string)) { // -> true alert(pattern.test(string)); // -> false break; } alert(pattern.test(string)); // -> true I have a form with several types of checkboxes, and I'm trying to check all but one of them to determine if any of those have been checked. I do not want to check 'all', but I want to see if any of the 'check_' or 'check2_' checkboxes have been checked. There are a variable number of checkboxes, so this is just an example with two of each. Set 1 and Set 2 will always have the same number of checkboxes as each other, though. I'm having trouble getting the function to do this - so any guidance would be appreciated. Code: <script language="JavaScript"> function checkForNone() { checked=false; for (i=0,n=selectForm2.elements.length;i<n;i++) { if (document.selectForm2.getElementById("check_"+String(i)).checked || document.selectForm2.getElementById("check2_"+String(i)).checked ) { checked=true; } } if (checked==true) { alert("OK!"); return true; } else { alert("Please select at least one checkbox."); return false; } } </script> PHP Code: echo " <form name='selectForm2' id='selectForm2'> Overall: <br> <input type='checkbox' name='all' value='' class='resultsAll' id='all'> Set 1: <br> <input type='checkbox' name='check_1' value='01' class='results1' id='check_1'><br> <input type='checkbox' name='check_2' value='02' class='results1' id='check_2'><br> <br> Set 2: <br> <input type='checkbox' name='check2_1' value='01' class='results2' id='check2_1' disabled='true'><br> <input type='checkbox' name='check2_2' value='02' class='results2' id='check2_2'> <br><br> Check for none selected <input type='button' onclick=\"checkForNone();\" /> </form> "; Hi, So firstly this is likely not in the right place at all, as it's a bit OT but I figured it's the best place to ask.. I have to document 4 different tests to my code; what structure should I take when doing this? I was thinking: * State the aim of the test * State the inputs, and what I believe the output should be. * State the actual output, and whether this positively or negatively affect my code. Hi, I have the below function and I keep getting the error Lid is not defined. Code: <script type="text/javascript"> function loadTips(file,ID,File,id){ alert(file); alert(ID); alert(File); alert(id); loadXMLDoc(file,ID); var l=setTimeout("loadXMLDocRefresh(File,id)",10000); } </script> My trigger button is: <input type="button" class="button3" value="Tips" onclick="loadTips('getTees.php','txtHintTees','getLees.php','txtHintLees')" /> So my alert Lid comes up with txtHintLees, so it is working up until the alert. Which leads me to believe that maybe it doesn't like being wrapped in "", without "" though firebug halts the process. I tried wrapping it in {} e.g. {loadXMLDocRefresh(File,id)} but that wasn't liked either. I'll stop my list of things I tried that don't work now. But does anyone have any ideas? Please help, I have built a HTML5 ap with local database using phonegap, I am now testing in xcode... my ap works fine in Web Kit browser but when I test on my iphone through xcode, I get the error message: There has been an error: no such table: **** here is my code: Code: <script type="text/javascript"> var html5rocks = {}; html5rocks.webdb = {}; html5rocks.webdb.db = null; html5rocks.webdb.open = function() { var dbSize = 10 * 1024 * 1024; // 10MB html5rocks.webdb.db = openDatabase("Todo", "1.0", "Todo manager", dbSize); } html5rocks.webdb.createTable = function() { var db = html5rocks.webdb.db; db.transaction(function(tx) { tx.executeSql("CREATE TABLE IF NOT EXISTS bmical(ID INTEGER PRIMARY KEY ASC, height1 TEXT, weight1 TEXT, bmires TEXT, added_on DATETIME)", []); tx.executeSql("ALTER TABLE bmical ADD bmires INTEGER"); }); } html5rocks.webdb.addTodo = function(todoText) { var db = html5rocks.webdb.db; db.transaction(function(tx){ var weight1 = document.getElementById("weight1").value; var height2 = todoText / 100 var BMI = weight1 / (height2 * height2) var BMI = BMI; var bmires = BMI.toFixed(3); var addedOn = new Date(); tx.executeSql("INSERT INTO bmical(height1, weight1, bmires, added_on) VALUES (?,?,?,?)", [todoText, weight1, bmires, addedOn], html5rocks.webdb.onSuccess, html5rocks.webdb.onError); }); } html5rocks.webdb.onError = function(tx, e) { alert("There has been an error: " + e.message); } html5rocks.webdb.onSuccess = function(tx, r) { // re-render the data. html5rocks.webdb.getAllTodoItems(loadTodoItems); } html5rocks.webdb.getAllTodoItems = function(renderFunc) { var db = html5rocks.webdb.db; db.transaction(function(tx) { tx.executeSql("SELECT * FROM bmical ORDER BY added_on ASC", [], renderFunc, html5rocks.webdb.onError); }); } html5rocks.webdb.deleteTodo = function(id) { var db = html5rocks.webdb.db; db.transaction(function(tx){ tx.executeSql("DELETE FROM bmical WHERE ID=?", [id], html5rocks.webdb.onSuccess, html5rocks.webdb.onError); }); } function loadTodoItems(tx, rs) { var rowOutput = ""; var todoItems = document.getElementById("todoItems"); for (var i=0; i < rs.rows.length; i++) { rowOutput += renderTodo(rs.rows.item(i)); } todoItems.innerHTML = rowOutput; } function renderTodo(row) { return "<li>On: <span>" + row.added_on + "</span> Height: <span>" + row.height1 + "cm</span> Weight: <span>" + row.weight1 + "lbs</span> BMI: <b>" + row.bmires + "</b><a class='delete' href='javascript:void(0);' onclick='html5rocks.webdb.deleteTodo(" + row.ID +");'>Delete</a></li>"; } function init() { html5rocks.webdb.open(); html5rocks.webdb.createTable(); html5rocks.webdb.getAllTodoItems(loadTodoItems); } function addTodo() { var height1 = document.getElementById("height1"); html5rocks.webdb.addTodo(height1.value); height1.value = ""; } </script> |