Jump to content

Jack McKalling

  • Posts

  • Joined

  • Last visited

Everything posted by Jack McKalling

  1. The javascript reference contains pages for all object types, like Array, Boolean, Date, Math, String. But not Object itself. There is a page for "Global" properties and functions, "Operators" and "Statements", but things like Object.create(), Object.values(), Object.keys() etc aren't on any of those pages either. Are these methods not documented because of lack of support on W3Schools for the relevant javascript version, or can Object be added to the reference pages? I'd like to see Object documented here, and not need to go to the MDN. Thanks for letting me know *Edit: I phrased it as a question, but it's really a suggestion, isn't it.
  2. For some reason the W3Schools website is not reachable in IE8. It simply gives a direct HTTP error and I cannot view any page. However the forum works just fine, but that is on a different domain anyway. Why is this? Is this a decision from W3S, to kick browsers that are too old, or is it some browser setting I myself overlooked? Because I find it very weird that W3S, who themselves are teaching how to be cross-browser, are not even compatible at all with this one. I was just trying to figure out whether I should be using the "lightgrey" or "lightgray" colourname, and I know IE8 is the browser that is specific on the difference, but I sadly cannot open this w3schools page about it in that browser because of this, or even any w3s page at all. I'm not necessarily asking for W3S to be compatible with IE8 if this is intended behavior, I know the browser is anciently old and I'm a dinosaur still trying to use it these days, but I just want to know why it is because this is strange. Thanks for your help.
  3. Hey, wonderful! New wow looks
  4. So you see, it all comes down to our definition. I never really agreed with wikipedias statement there because I thought OOP was only really a meaningful term if it is distinguised from classless programming (most languages work with objects anyway). This prototyping of JavaScript is quite different from my definition here, and though both methods could have their pros, I think I prefer the latter. But I don't want to start a discussion on which is better, I only need to point out I should have phrased myself from the start. Like this:Programmers who are (only) used to define classes like in e.g. C# or Java, will probably find the prototyping syntax of JavaScripts' OOP kind of weird. They are used to know what type every object is, more so because of the strongly-typed languages, rather than modifying the type from an instance pointer.Man I really hate explaining myself, I don't know why I'm so different.</OOP_subject>Aside from this advanced subject, I hope the return statement has become more clear to you now, newrehmi. Feel free to come back if needed.
  5. From my definition, prototyping has nothing to do with OOP. It may provide a means to create objects and such, but does this mean it is OOP? As previously mentioned JavaScript saves almost anything as objects. But compared to Java, C#, or even PHP's OOP implementation, JavaScript really isn't object oriented, right?Though it's often proven that some of my definitions are somewhat off to what's usually accepted, and that may apply here too. But it doesn't mean I never have my reasoning. I might seem off or backwards, and you're probably right, but when I mention OOP, I refer to using class definitions and inheritance etc. only, which is a much better way of programming if it were available in JavaScript. Prototyping is different, so this is my reason to say, prototyping, it is weird when you're experienced in "OOP". Am I using a different definition of OOP than you?You do agree with me class definitions are far better than prototyping, don't you? If so, then forget our definition differences as we'd be on the same line after all.It is not so important though, JavaScript doesn't know better, and I just mentioned my worthless opinion there.
  6. @ShadowMage,The reduction in parameters is what I also had in mind, but I thought just to first show the idea of parametering what was already global. I didn't know setTimeout() also accepts an anonymous function though, thanks! The tutorial doesn't explain the type of that argument quite clearly (they call it a "reference", but use a string in their own example). And what stupid of mine, default values of parameters, lol. I haven't been using either PHP or JavaScript for a while now, obviously I'm mixing things up a little here.I fully agree with you that the custom function is confusing. If you're an experienced OOP programmer like I am, the prototype and createDelegate() stuff of the JavaScript language really doesn't make any sense. thescientists example is much clearer on what it does, this actually begins to look like a conventional class definition!
  7. I believe you might write this function completely using parameters, eventhough you're using the setTimeout() function.Bear in mind the setTimeout() requires you to pass the function call as a string argument, as this means you can't simply pass in arguments to your function normally. You have to include the result of any argument into that string, which I present here: <script type='text/javascript'>//var text; //not necessary anymore//var texttobePlaced;//var theLoop = 0;function generateText(text="", textToBePlaced="", theLoop=0) { text = document.getElementById('thetext').value; var textlength = text.length - 1 if (theLoop <= textlength) { var randomSpeed = Math.round(Math.random()*200) texttobePlaced = text.charAt(theLoop); document.getElementById('text_place').innerHTML += texttobePlaced theLoop += 1; setTimeout('generateText("' + text + '","' + textToBePlaced + '",' + theLoop + ')',randomSpeed) } }</script> -You now don't need globals anymore (you'd have to test this though, haven't tried this much) because the variables are passed as arguments to the function every timeout.-I also added default values to the parameters, so if the function is called without arguments (i.e. the first time) they'll be initialised nevertheless.-Also notice you can use the "+=" operator to concatenate strings or increment integers.-Please notice the weird way of passing arguments in the setTimeout() function. The variables are concatenated to the string and embedded in double quotes if they represent a string themselves. This is important for it to work, as the scope of these variables is within the function where setTimeout() is called, not in the string of its argument. So you just have to concatenate them between the string. Again, you'd have to test this, this is only my second time I've tried it this way.
  8. I don't know if global variables make your browser slow, but it does provide the certain danger of conflicts between scripts that you installed together. A global variable should not be used by multiple functions unintentionally, and if they are global, this is precisely what would be possible.In my opinion, it should always be visible where a variable comes from, and in what scope it is active. In OOP this is quite obvious if you fully qualify them, but in javascript, there is no such thing. So to keep things readable, I'd say just try to use just the one scope of every function, and not the global one, for declaring variables. Naming conventions might work to "qualify" a variable visibly, but wouldn't syntactically.@boen_robot: you got me there... glad that I'm not concerned about this in my work
  9. That's right. I totally forgot about "normal use" of objects and assumed the use was referring to OOP.I think my only use for global variables is/was for preloading images with javascript, but then again, I don't use that anymore either because of the sprite-technique.My own reasoning behind not recommending global variables is that this scope is used to declare functions only, in the head section of your page. I see this section as a declaration of modules, and no actual execution of code.
  10. But I suppose if multiplication or addition is all you want, you probably don't need both of these values returned by the same function at the same time. For other cases, this is the way to do it though.There is another option to 'return' multiple values, but this is more like a hack and better done in OOP context.You can instead of hard returning a value, also change a variable or property that was created outside the function scope. If you change such a value from within the function, you don't need to return it from the function as it is already avaliable outside. This is not recommended programming though. If such variable management is necessary, consider learning the way of OOP programming instead. OOP stands for Object Oriented (Programming), and is what (I think) Deirdre's_Dad refers to with "using objects".
  11. Correct, the return-statement returns code execution, so really any code that follows it is skipped. You cannot return multiple values precisely because of this, the only way of doing so would be by combining the values in one value, like an array (like Deirdre's_Dad explains below). You can also make the calc(x,y) function callable with a third parameter that is of boolean value, to indicate whether you want to add or multiply, and return the appropriate value by conditioning on the value of this parameter. <head><script type='text/javascript'>function calc(x,y,multiply) { var sum = x + y; var rum = x * y; if (multiply == true) return rum; //else return sum; }document.write(calc(5,2,false)); //7document.write(calc(5,2,true)); //10</script></head> There are a lot of different ways to write this function. In my example here I've chosen an IF-condition to check on the value of the third parameter, but you could also use a conditional statement to compress this into one line: <head><script type='text/javascript'>function calc(x,y,multiply) { var sum = x + y; var rum = x * y; return (multiply == true) ?rum :sum; }document.write(calc(5,2,false)); //7document.write(calc(5,2,true)); //10</script></head> Or if this code is all you need, even more compressed: <head><script type='text/javascript'>function calc(x,y,multiply) { return (multiply == true) ?x*y :x+y; }document.write(calc(5,2,false)); //7document.write(calc(5,2,true)); //10</script></head> (notice I check the value of the multiply parameter if it is of boolean TRUE, you could also leave the equality check if you're sure the parameter is always a boolean)
  12. Just as I explained, the onsubmit handler is using a value. If you return false from it, it will of cource cancel the event, but if you only call a function, it will not, regardless of the return value of that function. Unless you RETURN the return-value of the function like in above example :)This might seem a little weird for you in the beginning. But this eventhandler is, if you want to know, a separate code scope from the event itself. It will only cancel the event if it returns a value, just like your function does. If the handler calls a function itself, the return value must be returned from the handler too.
  13. You'll also want to return the value of the function to the event itself, simply calling it won't be enough in my experience.Using your example, the code will look like the following, taking ShadowMage's correct suggestion in account: <head><script type='text/javascript'>function denySubmit() { alert('you will not going anywhere'); //but the the form will now NOT load the 'lol.php' return false; }</script></head><body><form action='lol.php' method='get' onsubmit='return denySubmit()'><input type='text' name='myText' /><input type='submit' /></form></body> The reason for this, is that the onsubmit attribute of the form-element, is just a handler. When the event occurs, the handler will first be called, and as it calls another function, the return value of your function must be returned from the handler to the event itself to cancel the event.I also added a name attribute to your textfield, as that will be the accessible name for this field within lol.php. You can also choose to use the POST method instead of GET, if you want to be save and not overflow or expose the data in the URL.To add to ShadowMage's reply, the return-statement is used to return code execution from anywhere within a function back to wherever it was called, and returning a value with it is only optional. You can for instance also return from a function if a certain condition is met, to prevent the rest of the function. A simple example below: function test(){ if (document.getElementById("myCheckbox").checked != "true") return; //this code will not be executed it the checkbox is not checked document.forms[0].submit();} If your function is returning a value, you can use this value when you call it, just as if the function call were a variable or property. Doing so will require the function to always return a value though, and result in an error if it for some reason doesn't.
  14. Hello,I'm new to using (MySQL) databases through Eclipse, and would like to know how it's done.Currently I have my project for a windows application. It's fully written in Java. But to distribute the app, I'm using an executable wrapper that packs up the jar and necessary files into one exe, and then I rar it along with some gfx and sfx folders into one nice archive. The idea is that I further develop this windows application using a MySQL database (which I hereby want to start using), untill I port it to an applet for websites and then switch to an existing online MySQL server. If it is possible, I actually like to keep both windows distribution and website applet separately available using their own database when it comes to that.Because I'm having the (MySQL using) applet in mind, I think I should start with implementing a MySQL database. I'm not familiar with other DBMSs. But if there is a portable solution for another DBMS, please tell me.One of my questions would be, do I need to install the Connector/J to be able to use a MySQL database, or did the driver come bundled with Eclipse? As I just recently installed the Indigo version and got the Connector/J driver from mysql.org, but I don't know what to do with the latter. I researched myself, but can't find a simple answer. I know that NetBeans is bundled with these type4 drivers, so if Eclipse isn't, why not?So if I want to start using a database, keeping in mind it will eventually be redirected to an existing online one, what DBMS options do I have, should I use a bridge or not, what else do I need, and how do I do it? Please help Thanks,Jack
  15. You're right about the origin of this account, did you remember that? But you're slightly inaccurate about the irony part. We had an aggreement that I should take over all of his work and memberships, and continue on his ideas for a website. I quite did not force it, in fact, I was given permission. This was all a long time ago though, long before the post you refer to.It may seem a little confusing, I understand. But I don't really want to talk about the origin. I'm the only one now, and anything that has recently come up as one of my threads is in fact really mine. I wouldn't have posted my alias name in that post though, if I knew it would be used elsewhere. I should have thought about that better then. It is much more about the history of the name that I invented rather than the post it is in.I feel some of you don't understand or share the same value as I do, and I respect that. I don't need to persuit this further if I don't want to, but please do understand that there is thus more to the name than initially obvious. I chose an alias because of the same reason why the original owner requested my intervention in the first place. So I do feel bound to protect it.*Edit:I'll just remove my name there to prevent any further mishaps.
  16. Thanks Sigord.It is indeed a good question why people publish supposedly private material. In the case of my own posts here, I really cannot help it or do anything myself to prevent infringement. I would have a question that I submit to this board for the technical answer it could receive, but my posts are not hidden to the public. W3Schools leaves the forums open for guests to read, as the community here isn't supposed to be closed eventhough individual posts might claim privacy.However, as you've pointed out, (almost) all material on the internet is automatically copyrighted. Should I assume that I do have right to take anyone down? I don't think I have what it takes to do just that, but I don't like to look down either. My request for posts on W3Schools would be that I am properly addressed, accredited, or at all mentioned as the first author, or not to use the posts at all. Eventhough the board is public, as it should remain that way.Hereby aggreed that public material should not be assumed uncopyrighted, for as supposed private content could belong to something bigger that is actually public.Lastly, still the only real thing I think is possible here, that would prevent infringement, would be to require guests to log in before they may read our topics. As is done on closed communities. But should W3Schools do that? Shouldn't our efford be available to new programmers and developers who only want to read up on us?
  17. Hello,Sorry if this is the wrong forum, it was really hard to decide.Last notification I received about a new reply to one of my topics, gave me a warning that the message might not have legitimately been sent by gmail. I've read Gmail's helppage, and now I forward it to you. Can you do something about it, or should it be presented at IP Boards?Gmail says it is possible to add specific information to the message headers, but that's not my best field of expertise.A reason why this should be looked into, is that it might help preventing a classification as spam.Thanks for your help,Jack
  18. Aye, I wish the internet provided more security.No need for policing, but definately no need for thieves either.
  19. No of cource not. I don't mind websites taking my posts, it's my name that was in it.I am glad that my name is an alias in the first place, but it just doesn't feel right that it appears on a site that I've never visited.*Edit:Oh yes, sorry. This contradicts my first post. I just mean that whenever I submit a text that actually has my name in it, I would want the occurance of this text to credit the name. You wouldn't want to be mentioned anywhere without appropriately being addressed.Other than that they can keep my posts, just not those with my name in it or without due credit.Content scrapers probably don't look into copyright notices anyway, and the site about the DOCTYPE post (link in OP), has actually been removed already.
  20. I didn't know W3Schools didn't control the server. I assumed the software was installed on their own, but looking at the domain, I should have known this.Contacting Invision Power seems a bit too far for this thing, I guess it would have been okay if W3Schools could have just done this. It doesn't matter though, if you're right, and that is what spinn3r said, Omgili is probably the same.As robot.txt is not a secure lock or a lock at all, if we really wanted to protect our posts here we should look into other means. There is one thing that comes to my mind, but this will probably hurt ourselves also. There is of cource the option to deny public access to the forums, but this means you must register to be able to read, and I think that goes against the spirit of the board. Anything else?
  21. It's fairly possible they lie about robot obedience. But it all seems legitimate, judging the whole website. They themselves mention the robot they're using and how to disable it, and I wouldn't think non ligitimate websites would do that. They're just a website delegating forum posts within their "search platform", and it seems they're just offering a backdoor for those who don't wish to participate in it.Maybe they are lying, but if they are, trying to disable the bot would not hurt anything, right? I see the possibility. My glass is half full :)I forgot how to contact W3Schools though.
  22. After my recurring check, I've now found Omgili too.This Omgili is some site who claims to be a search engine, and lists more than one of my posts accessible by google search.But this time I know what could be done about it.Omgili says they will obay "/robots.txt", and with a mention of the "omgilibot", I, and I mean W3Schools, could tell Omgili to stop indexing.So this is my question to W3Schools, are you using /robots.txt, and if so, could you modify it to deny Omgili? It's just one bot, but it helps. Maybe we can't take down infringing content, but maybe we can prevent anything further. It's just a "No Entry" sign really, not a lock, so where's the harm in adding it?
  23. So I see. Well my argument is that my name is used, in combination with my company name.Anybody can do anything with the information without knowing it is me. Over here I can just edit or delete it, but not over there.Its just that I want to protect my privacy. For instance, if you google my name, you'll only find posts on forums that I am a member of and my own website, but nobody else. That is not a coincidence...
  24. Hello, I have found a copy of a post from my writing, somewhere on the net.I am claiming the text there, I wish it to be removed, as I wish not to be not credited for any texts I write here.Still I wonder how copyright is handled on these forums, and what my rights are...Can anyone help me?Reference: http://ebookslab.info/free-tutorials/doctype-addition.htmlOriginal: http://w3schools.invisionzone.com/index.ph...st&p=177738*Edit:Another reference of the same post somewhere else: http://www.globberstack.com/Questions/doctype-addition-1/*Edit2:I've edited my name out of the original post, so content scrapers can do whatever they like to the texts now.
  25. Okay, so that is a little too complicated..Basically, (how) can you set a child of a 100% windowheight element, to fill its remaining space vertically (if there is also another sibling above it)?And I'm not looking for margining the child to cascade the other sibling from behind, I want this child to overflow:auto, without that scrollbar to disappear behind something else..
  • Create New...