|
golgo13sf posted:Nope. Just for clarification sake... In the code you posted above, what is it that links those functions to the submit/verification button? Im used to VB where you just code everything individually using common names. I cant seem to find the connection here.
|
# ? Oct 13, 2009 03:57 |
|
|
# ? May 23, 2024 17:47 |
|
Sointenly posted:Just for clarification sake... When the submit button is clicked it will trigger the form's onsubmit, which is where he's calling your validate function: form id="myform" onsubmit="return validateForm();" method="POST" action="submitpage.html"
|
# ? Oct 13, 2009 03:59 |
|
I'm currently working on a page in which that has a drop down menu similar to an option element. However, I need more than just text for each option so I'm using a div that I make appear and disappear. I've got the appearing working correctly, but I'm not sure how to make it disappear when I click anywhere on the page. Does anyone how I can accomplish this?
|
# ? Oct 13, 2009 17:19 |
|
CT2049 posted:I'm currently working on a page in which that has a drop down menu similar to an option element. However, I need more than just text for each option so I'm using a div that I make appear and disappear. I've got the appearing working correctly, but I'm not sure how to make it disappear when I click anywhere on the page. Does anyone how I can accomplish this? when you show your DIV, add a click hander to the document, check to see if the click was in your DIV, and if not, hide. When you hide, remove the click handler as well, so it's not checking when it doesn't need to.
|
# ? Oct 13, 2009 17:32 |
|
golgo13sf posted:Nope. First of all, thank you very much for all the help. Everything is working with the exception of one little bug. If both email fields are left blank, it will alert the user to enter an email, but then it also alerts the user that inputs were accepted (because it then goes on to check that email1==email2 and i assume it accepts two blank fields as being == ) code:
|
# ? Oct 13, 2009 19:19 |
|
Sointenly posted:First of all, thank you very much for all the help. Stick a "return false;" after each alert, like so: code:
Just-In-Timeberlake fucked around with this message at 20:18 on Oct 13, 2009 |
# ? Oct 13, 2009 20:13 |
|
quote:"return <value>" ceases all execution of that function and returns that value, kind of like an "exit function" statement in VB, except it returns a value. So you have a bunch of statements that return false on error and at the very end have a "return true;", if it gets to that point everything is ok and processing should continue. success! thank you
|
# ? Oct 13, 2009 20:23 |
|
What's the difference between this...code:
code:
|
# ? Oct 13, 2009 20:30 |
|
The first creates a new function instance for each object while the second only creates one function instance which is shared by all Book instances.
|
# ? Oct 13, 2009 20:36 |
|
Lumpy posted:when you show your DIV, add a click hander to the document, check to see if the click was in your DIV, and if not, hide. When you hide, remove the click handler as well, so it's not checking when it doesn't need to. That worked great, thanks!
|
# ? Oct 13, 2009 23:18 |
|
Edit: I'm an idiot. Ignore.
Flamadiddle fucked around with this message at 14:28 on Oct 21, 2009 |
# ? Oct 21, 2009 12:45 |
|
I wrote a Greasemonkey script that is supposed to run on someone's Facebook profile page. It grabs the user's ID which I found to always be in the same place in the link for the "Share" button as well as the user's name and then adds a link under their profile picture in the "profile_actions" div. For some reason, when I navigate to someone's profile (such as by clicking a link on my news feed), the new link doesn't appear. In fact it seems that the script is not running at all (I've tested this with an alert()). Only when I refresh the page AFTER navigating to it does the script run, and it runs successfully. Does anyone have any idea why this could be? Here's the code... code:
Thank you very much for any help in advance.
|
# ? Oct 22, 2009 07:22 |
|
Is navigating to someone's profile done via AJAX by the site, so there's no page load?
|
# ? Oct 22, 2009 15:17 |
|
Lumpy posted:Is navigating to someone's profile done via AJAX by the site, so there's no page load? Clicking on someone's profile link changes the header of the entire page. There's a whole browser/page reload so I don't think that's the issue, although I could be mistaken.
|
# ? Oct 22, 2009 15:49 |
|
Look at the page URL before and after clicking the profile link. If everything before the hash (#) is the same, then a real page load has not occurred.
|
# ? Oct 22, 2009 15:55 |
|
Nigglypuff posted:Look at the page URL before and after clicking the profile link. If everything before the hash (#) is the same, then a real page load has not occurred. Wow I did not notice this, that is exactly what is going on. If you click on someone's profile link from either the search results, newsfeed, or someone else's profile then the URL that you are taken to only changes from the current URL by info after the hash. What are my options here? Can I somehow detect when the new page is loaded and have the function be called? Rabbi Dan fucked around with this message at 17:34 on Oct 22, 2009 |
# ? Oct 22, 2009 17:15 |
|
Rabbi Dan posted:What are my options here? Can I somehow detect when the new page is loaded and have the function be called? You can do someNode.addEventListener("DOMNodeInserted", someCallback).
|
# ? Oct 22, 2009 18:21 |
|
Vanadium posted:You can do someNode.addEventListener("DOMNodeInserted", someCallback). I put my main code in a function called process() and then added this line to the bottom of the greasemonkey script: document.getElementById('profile_actions').addEventListener("DOMNodeInserted", process() ); This doesn't seem to do anything. Clearly that event is not being fired. How can I find out which nodes are having their DOMNodeInserted event fired when I navigate from profile to profile on Facebook?
|
# ? Oct 22, 2009 18:57 |
|
Are there any good JavaScript + canvas/SVG/whatever libraries out there that will let me draw interactive graphs? The graph-theoretical kind with nodes and edges, not charts. Basically I'd like to be able to let a user create finite automata diagrams and then be able to do things to them on the backend, so being able to label nodes/edges, and distinguish between different types of nodes, would be a necessity.
|
# ? Oct 22, 2009 19:57 |
|
Rabbi Dan posted:I put my main code in a function called process() and then added this line to the bottom of the greasemonkey script: I managed to get the DOMNodeInserted event working at the highest level (document) with the following line: document.addEventListener("DOMNodeInserted", process, false); Apparently that third argument helps... Anyways, this doesn't work because that event gets triggered so many times and my extra HTML gets appended to the profile_actions div over and over when I really only want it to go there once. This is the best solution I have gotten to work but I'm convinced there has to be a better way. code:
Any comments/thoughts on my solution? My fear is that if for some reason there is a network hiccup the 1.5 seconds won't be enough and the function will be called too early to work. If on the other hand I increase the 1.5 seconds, then it will result in a lovely user experience since that will mean more time waiting until the new link is added. Any further ideas on this topic?
|
# ? Oct 25, 2009 08:02 |
|
In newer browsers, you can also listen for the hashchange event.
|
# ? Oct 25, 2009 10:48 |
|
I came up with a robust solution that is just like the URL-change-detection one except it detects changes in the profile name DIV. This won't work if you go from one John Smith directly to another John Smith but I guess I'm over that. My only worry is that there could be some performance implication with calling a Javascript function every 250 ms but I haven't noticed anything yet. EDIT: just kidding, name-detection doesn't work when you're looking through photos and click a tag link to go to someone's profile. Rabbi Dan fucked around with this message at 18:50 on Oct 25, 2009 |
# ? Oct 25, 2009 18:48 |
|
So I'm building a list of messages on screen that the user will be interacting with. Moving in between different queues etc... I want to have a master array of all "messages" and that array is objects which are the messages themselves. They key of the associative array is an ID number that is randomly generated. Here is my test code so far code:
ATLbeer fucked around with this message at 01:28 on Nov 7, 2009 |
# ? Nov 7, 2009 01:26 |
|
ATLbeer posted:That's all well but, when I try to access the $.messages array in FireBug it goes into an "unresponsive script" hang. I guess there is an infinite loop somewhere but, I can't see it. Other problems aside, here is why you're hanging. code:
code:
|
# ? Nov 7, 2009 05:14 |
|
ATLbeer posted:So I'm building a list of messages on screen that the user will be interacting with. Moving in between different queues etc... If you want an associative array in javascript, just use a plain old Object instance. As you have seen, it may be technically possible to treat Array instances as sparse arrays with arbitrarily high numeric keys, but it will ruin iteration. The built-in Array class is spooky, and will automatically adjust its own length property — meaning that most of its methods will behave as if the array contains a whole lot of undefined items in-between the ones you actually assigned. In general, you only want to use an Array instance if you are actully iterating over or manipulating the contents as a dense list, eg pushing/popping items. Also: you don't need to be generating keys with Math.random(). Just do something like code:
Nigglypuff fucked around with this message at 10:35 on Nov 7, 2009 |
# ? Nov 7, 2009 10:29 |
|
I have a question for those who know javascript. I'm trying to create a favorite with javascript embedded to ask for a two character country abbreviation, and input that into the url to load. Example: open favorite input: CA loads url -> https://www.website.com/page.cfm?country=CA I know I've seen this before with searching.. I just can't seem to find it again.
|
# ? Nov 7, 2009 21:21 |
|
javascript:location = "http://www.website.com/page.cfm?country=" + prompt("Country code?")
|
# ? Nov 7, 2009 23:09 |
|
Nigglypuff posted:javascript:location = "http://www.website.com/page.cfm?country=" + prompt("Country code?") Thanks, that is perfect.
|
# ? Nov 8, 2009 02:21 |
|
I posted the following in the PHP thread: Soks posted:Anyone have any ideas for making an image scroll in the background slower than the rest of the page? I'm trying to make a neat 3D effect where instead of just having a static background and a foreground that scrolls normally, I want the foreground to scroll normally and the background to scroll slowly and in relation to the length of the page. http://inner.geek.nz/javascript/parallax/ And my implementation is here: http://www.cyf.mylha.com/index.php But this effect is very choppy in Firefox and Safari. It runs pretty smoothly in IE and even better in Chrome, but I really need a way to smooth this out for Firefox/Safari. Here's the code: code:
Also yes I know the pictures are blurry, the artist I'm making the site for is working on high res versions of everything and a new canopy (much better than my badly photoshopped one :v). Soks fucked around with this message at 19:03 on Nov 24, 2009 |
# ? Nov 24, 2009 18:53 |
|
Soks posted:[ choppy in Safari ] It was quite smooth in Safari for me. 4.0.4 on OS X 10.6.2
|
# ? Nov 24, 2009 20:21 |
|
Soks posted:I don't know JavaScript, but I was able to bumble my way around the code just fine. I just have no idea how this could be smoothed out, or why it's choppy in the first place. I haven't checked this in Safari, but it looks like Chrome and Firefox implement the onscroll event differently. Basically, Chrome emits many more onscroll events than Firefox does, and most importantly, it emits an event every time the page is redrawn while scrolling. Firefox, on the other hand, boasts a 'smooth scrolling' feature. Smooth scrolling means rendering many brief, incremental frames while scrolling — but the onscroll does not fire every time one of these frames is drawn to the screen. Rather, the event is only fired during pauses in the movement of the scrollbar, when there is no incremental movement to render. This means that in Firefox, during the act of scrolling, many small changes in scroll-height are rendered to the screen before your handler is called, and so the movement of the different layers will appear to be jerky and out of sync. I have not yet found a solution to this problem. My first impulse was calling setInterval() to check the scrollY property of the page at a high frequency, and call your handler when its value changes, regardless of whether an onscroll event has occurred yet. Unfortunately, it looks like Firefox also does not update the scrollY property smoothly during scrolling. In other words, there appears to be no way of testing whether or not a visible scroll has occurred until the actual onscroll event has fired, and by that point too much scrolling may already have occurred to make the parallax effect seem smooth. Sorry to not be more helpful! Nigglypuff fucked around with this message at 10:14 on Nov 25, 2009 |
# ? Nov 25, 2009 10:03 |
|
Soks posted:
|
# ? Nov 25, 2009 17:06 |
|
Nigglypuff posted:Sorry to not be more helpful! peepsalot posted:position:fixed Thanks alot guys, I'll keep looking around for a solution.
|
# ? Nov 25, 2009 20:20 |
|
Comedy "make your own scrollbar in HTML and synchronize everything so it updates simultaneously" option.
|
# ? Nov 25, 2009 21:04 |
|
I was just considering almost exactly that. Would there be a way to emulate additional onscroll events if the scroll bar was made in Java or something? I don't know. I'm just brainstorming, I think I need to pick up a Java Script book or something.
Soks fucked around with this message at 21:42 on Nov 25, 2009 |
# ? Nov 25, 2009 21:28 |
|
Soks posted:Would there be a way to emulate additional onscroll events if the scroll bar was made in Java or something? Just make the page a giant Java applet.
|
# ? Nov 25, 2009 21:33 |
|
Yeah, no. :v Is there a way for Java Script to get the entire length of the page, and then is there a way to catch mouse wheel input other than onscroll?
|
# ? Nov 25, 2009 21:41 |
|
Soks posted:Is there a way for Java Script to get the entire length of the page If you're thinking what I think you're thinking, then just use percentages instead.
|
# ? Nov 25, 2009 21:45 |
|
rt4 posted:If you're thinking what I think you're thinking, then just use percentages instead. Yeah, exactly! But it has to have a minimum speed somehow... Otherwise the background image will scroll hilariously fast on shorter pages. Edit: Oh I see what you meant. Yeah, if not for that worry about speed, I could just use percentages. Soks fucked around with this message at 21:56 on Nov 25, 2009 |
# ? Nov 25, 2009 21:52 |
|
|
# ? May 23, 2024 17:47 |
|
I have a jQuery plugin which according to it's comments has a public function to destroy a tooltip. However it doesn't seem to actually be attached to anything according to firebug. I can see it being added to the $this but it doesn't stick around after the closure ends. This is the whole js file http://github.com/lukasbob/Tooltip-Toolbox/blob/master/js/tooltip.js This is the plugin demo page if anyone wants to debug with firebug http://tooltip-toolbox.lukasbob.com/ The specific bit I want to use to remove tooltips with code:
code:
I'm using this tooltip plugin because it allows me to bind to focus and blur. I'd happily switch to a different one that someone knows both offers custom event binds for show and hide and also allows tooltips to be destroyed. stack fucked around with this message at 00:43 on Nov 26, 2009 |
# ? Nov 25, 2009 23:56 |