Jump to content

Beta

Members
  • Posts

    30
  • Joined

  • Last visited

Posts posted by Beta

  1. function XHR() {   var _handler;   if(window.XMLHttpRequest) {	  _handler = new XMLHttpRequest();    } else if(window.ActiveXObject) {	  try {		 _handler = new ActiveXObject("Msxml2.XMLHTTP");	  } catch (e) {		 _handler = new ActiveXObject("Microsoft.XMLHTTP");	  }   }   return _handler;}function startup() {   var xmlHttp;   xmlHttp = XHR();   xmlHttp.onreadystatechange = stateChanged;   xmlHttp.open("POST", "bringmethedata.php", true);   xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");   xmlHttp.send("");}		function stateChanged() {   if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {	  document.getElementById("letPHPdothework").innerHTML = xmlHttp.responseText;	   }}

    Why are use using the POST method, yet sending no parameters? o.o

  2. Well, i've seen my fair share of people complain about crossbrowser compatibility. And, they always have their own ways of checking for IE. Whether it be the ActiveXObject, or even the document.all...maybe even an appName check...So, how do you check?For me, i'm trying to use this more often:

    function isIE() {   if((new Array()).__proto__ != Array.prototype) {	  return true;   } else {	  return false;   }}

    hehehehehehe :)

  3. For telephone numbers, it's different. You would need to match either(#)? ### ### ####or### ####So, it would be along the lines of ((\d{1}\s)?(\d{3})?\d{3}\s\d{4}Atleast, i think that's how it would be done :/By the way, i was wondering about your lines.you have \s{2,*}...would that match for only 2 spaces in the entire string, or only 2 spaces in a row...?

  4. Ah, but to get the value from the database, you'll need server-side technologies - even using AJAX.
    Then use something other than a database :) Such as FF's globalStorage and IE's userData. Or you could have a webpage with keys and values that are auto-generated according to the user's persistent data value :)
  5. I'm guessing you're going to need some server-side code to accomplish this. If the encryption algorithm is done in javascript, anyone with a passing knowledge of javascript will be able to crack it.
    Yes, but thats why you create two encryption functions that need keys to operate :) The keys are stored in a small database, then accessed via AJAX and used to decrypt the cookie and eval the main function :)Each encryption has a different key used to decrypt it :)
  6. Instead of making them equal to each other like your doing, why not create a prototype type function for that object that copies the values of one object, to the other?function Object() {blah}Object.prototype.copy = function(obj) {blah obj blah}var 1 = new Object();var 2 = new Object();1.copy(2);

  7. i see pulpfictions going to answer this one...so ill just add something :)Instead of using the full document.getElementById(id);, you can use shorthand functions or variables :)var getID = document.getElementById;orfunction getID(id) { return document.getElementById(id);}to use either, its:getID("id");

  8. use Arrays :)have a list of arrays like this:

    var Menu = new Array();Menu[0] = ["1", "2", "3", "4", "5"];Menu[1] = ["1", "2", "3", "4", "5"];Menu[2] = ["1", "2", "3", "4", "5"];function MenuClick(menu) {   var List = document.getElementById("model");   for(var a = 0; a < List.getElementsByTagName("option").length; a ++) {	  List.getElementsByTagName("option")[a].innerHTML = Menu[num][a];   }}<option onclick="MenuClick(0);">Type 1</option>

    Something like that should work...although you may want to tidy it up, and make it more...well...useful and bigger..loli think you can also put arrays inside arrays:Menu[0] = [["0 innerHTML", "0 other stuff"], ["1 innerHTML", "1 other stuff"]];then have Menu[menu][a][0] or Menu[menu][a][1] :)

  9. Yea, i see where your coming from, and that's most likely the best method, as all of your scripts are in the head element. But i like to just keep the function inside one script tag rather than create another one to execute it, or using window.onload and setTimeout :)Also, most of my functions execute themselves :) So i cant really do it later on in the pages source :)

  10. I think they are usually declared in the head because the head is parsed by the browser before the body. If you have an element in the body which calls a function, that function will need to have been declared or else you'll get an error. Putting the functions in the head helps prevent this from happening.
    Also, you might want to put the function in the body if you have it alter HTML that is after the head element :)
  11. There isn't, but i've made a prototype function that makes a String glow random colors at a setInterval rate....so i was trying to make it find that span tag instead of looking for a tag that i create myself :/See, this is all for an InvisionFree forum. The tag auto-parses to a span with the color value assigned to it. i wanted to try [color*=rainbow], as it creates a span with that color already assigned, so that i would have to parse the tag myself :/ but i guess theres no real way around it as the HTML doesn't even allow it :)...lol

  12. This works:

    <script type="text/javascript"><!--var search = "news";var myarray = new Array(3);myarray[0] = "news world";myarray[1] = "computer";myarray[2] = "my news world";for(var x = 0; x < myarray.length; x++) {   if(myarray[x].match(search)) {   document.write(myarray[x] + "<br />");   }}// --></script>

    1. You don't need to inlude the var max = myarray.length, and you had a "," in your for statement.2. You were missing a "(" and ")" in the if statement.:) hope that helps

  13. <span style="color: rainbow"></span><script type="text/javascript"><!--var Span = document.getElementsByTagName("span");for(e = 0; e < Span.length; e++) {   if(Span[e].style.color == "rainbow") {   Span[e].innerHTML = "RAINBOW!!!";   }}// --></script>

    Anyone know why that doesn't work? I'm thinking it's because "rainbow" isn't a default color...but should that even matter? o.o

  14. Wouldn't something like this work also?

    divHl=document.getElementsByTagName("div");for(i=0;i<divHl.length;i++) {  if(divHl[i].className=="parent") {   inDiv=divHl[i].getElementsByTagName("div");	for(j=0;j<inDiv.length;j++) {	  if(inDiv[j].className=="header") {		inDiv[j].onclick=function() {		alert("lol");		}	  }	}  }}

    Also, the whole onclick = function; never works for me=/

  15. Well, i've been fooling around with objects and such, and i know that you can either useObject.variable or Object['variable']....well, you can do the same with RegExp...right?RegExp.$1 and RegExp['$1'] both work...but why do people only use RegExp.$1 rather than the other? Is it just because its easier, a preference...or because they don't even know you can use ['variable']?Also, is using one method (. or ['']) better than the other? o.o

×
×
  • Create New...