Jump to content

Beta

Members
  • Posts

    30
  • Joined

  • Last visited

Everything 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. http://www.javascriptkit.com/javatutors/co...alcompile.shtml'...Include comment tags in your script in a way that ensures browser compatibility..."
  4. Actually, use the global and multiline flags on this./regexpstuff/gim; that might solve your problem...o_O
  5. 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...?
  6. Yes, and while i don't normally use Wikipedia, they have a nice reference to most of the characters included in Regular Expressions http://en.wikipedia.org/wiki/Regular_Expressions
  7. To check for something to appear more than once, doesn't a simple {#} work? Where # = the number of occurences you want to check for.\s{2} would check for 2 whitespaces i think
  8. Beta

    30 day timeout

    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
  9. Beta

    30 day timeout

    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
  10. Beta

    30 day timeout

    Just add a cookie that expires in 30 days, then have the script check for it:p Have the cookies name and value encrypted so that the user cant cheat and make another one though...lol
  11. 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);
  12. 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");
  13. 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]
  14. 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
  15. You could, but it's easier to load it after :)Atleast, i think so
  16. Also, you might want to put the function in the body if you have it alter HTML that is after the head element
  17. globalvar = myField;setTimeout("globalvar.focus()", 0); That should work also...can you even do setTimeout with 0?https://bugzilla.mozilla.org/show_bug.cgi?id=236791
  18. o, so it's like an external JS file that contains an array of custom and useful functions?
  19. What exactly is a toolkit anyway? o.o
  20. What would you need a read only object and variables for?
  21. Beta

    style.color...?

    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
  22. 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
  23. <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
  24. Beta

    Tree Menu

    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=/
  25. Beta

    RegExp

    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...