|
I have this code in a frame (the kind with a frameset and everything):code:
edit: unfucking mixed newlines Munkeymon fucked around with this message at 21:41 on Mar 30, 2010 |
# ? Mar 30, 2010 18:23 |
|
|
# ? May 17, 2024 18:28 |
|
Try $(window).load(...) instead.
|
# ? Mar 31, 2010 17:32 |
|
Nigglypuff posted:Try $(window).load(...) instead. That does work and .ready() probably does as well. I'm just an idiot for copying and pasting an old version of Google's URL. _gat didn't exist when I was calling it because urchin.js doesn't define a _gat object - ga.js defines a _gat object. Munkeymon fucked around with this message at 18:06 on Mar 31, 2010 |
# ? Mar 31, 2010 17:59 |
|
Has anyone else had problems getting a (document).click event to work with Chrome? This works perfectly in FF but it doesn't seem to fire the event at all in Chrome... Google isn't too helpful. edit: I should add that this is using jQuery. Let's assume I'm just doing this. code:
noz fucked around with this message at 11:10 on Apr 1, 2010 |
# ? Apr 1, 2010 10:17 |
|
noz posted:Has anyone else had problems getting a (document).click event to work with Chrome? This works perfectly in FF but it doesn't seem to fire the event at all in Chrome... Google isn't too helpful. Sounds like a focus issue or something else is capturing the event and not letting it bubble.
|
# ? Apr 1, 2010 11:58 |
|
Chrome's excellent dev tools (seriously, I'm not being sarcastic here) let me find the problem pretty fast. Some judicious use of jQuery.noConflict() resolved it. Thanks for the reply!
|
# ? Apr 1, 2010 12:21 |
|
noz posted:Chrome's excellent dev tools (seriously, I'm not being sarcastic here) let me find the problem pretty fast. I agree. I wish I had them on the platform I'm working on right now. Even Mozilla's would be nice. Doing everything with debug statements to a log file is a pain.
|
# ? Apr 1, 2010 12:48 |
|
I have a long string that is a mixture of digits and the uppercase letters A through J. I want to replace every occurence of 'A' with '0|', every occurence of 'B' with '1|', ..., and every occurence of 'J' with '9|'. I looked for how to do this on the internet, but the answers I found all said that the only way to replace every occurence of a substring was to use regular expressions and supply the 'g' modifier. Is that really correct? Do I really have to docode:
|
# ? Apr 3, 2010 15:23 |
|
Hammerite posted:Do I really have to do If the order of replaces doesn't matter, you could put the mappings into an object and iterate over the properties of the object. code:
Also, looks like you can use another loop to generate the map.
|
# ? Apr 3, 2010 15:56 |
|
You can also pass a function as the second argument:code:
|
# ? Apr 3, 2010 16:46 |
|
Thanks both of you. I've used barbarianbob's solution, since the cross-browser usability is an advantage. I'm glad there's a one-line solution, it's nice to be able to just "drop it in".
|
# ? Apr 3, 2010 18:01 |
|
Hi I'm trying to add a .current class to the div#sidebar li that has text inside that matches some text that identifies each page (uniqueid). The actual site is on wordpress which generates the <li>'s and changes the page identifying text for me. Also I've never written a javascript thing like this and don't really know what I'm doing. Here's what I have on my test page: code:
Where did I go wrong? edit: ok someone I know wrote this which works: code:
last edit: The problem appears to have been the semicolon at the end of the 'for' line. This is going to be so awesome on the wordpress site! Grumpicat fucked around with this message at 22:08 on Apr 3, 2010 |
# ? Apr 3, 2010 21:12 |
|
Grumpicat posted:Hi I'm trying to add a .current class to the div#sidebar li that has text inside that matches some text that identifies each page (uniqueid). After taking a quick look, two things popped out at me. First, get rid of the semicolon from after: code:
code:
Third, as a fellow Javascript newbie, I really, really recommend using the jQuery framework and a good debugger like Firebug.
|
# ? Apr 3, 2010 21:50 |
|
Haystack posted:things The problem was indeed the semicolon at the end of the 'for' line. So you were right! I did try to use jquery but my image slideshow totally broke when I linked to the jquery.js. Kinda weird. Also thanks for the tip about firebug. edit: wow im editing like crazy here. The setAttribute I made works I think so maybe the semicolon was the only problem. Grumpicat fucked around with this message at 22:08 on Apr 3, 2010 |
# ? Apr 3, 2010 22:03 |
|
How did you link to jQuery? use wp_enqueue_script('jquery'); and you should be good. It might even be included if you use a bunch of plugins. Just remember that it gets loaded with the no conflict stuff there.
|
# ? Apr 3, 2010 22:56 |
|
Ned posted:How did you link to jQuery? I put code:
code:
code:
I'm not too worried about jQuery tho I'm almost done with this site now.
|
# ? Apr 4, 2010 01:58 |
|
I have some variables that are being treated as undefined, but I don't understand why. I have a JS file included that looks like this code:
code:
|
# ? Apr 4, 2010 05:11 |
|
rt4 posted:I have some variables that are being treated as undefined, but I don't understand why. Your image var is scoped to the anonymous function. You probably want to do something like this: code:
Lumpy fucked around with this message at 15:16 on Apr 4, 2010 |
# ? Apr 4, 2010 15:09 |
|
Thanks, Lumpy. That's the explanation I was looking for. I hadn't done any (serious) JS in a couple months and somehow had the idea that everything was a global.
|
# ? Apr 4, 2010 15:29 |
|
Grumpicat posted:I put Write your code like this when you include it that way. code:
|
# ? Apr 4, 2010 15:38 |
|
Ned posted:Write your code like this when you include it that way. Still not getting anything :/ Does it make a difference that the site isn't hosted on wordpress?
|
# ? Apr 4, 2010 18:59 |
|
I'd like to replace this junk:code:
|
# ? Apr 5, 2010 23:01 |
|
Munkeymon posted:I'd like to replace this junk: Pretty sure Prototype will treat that argument as an ID, so if you try $('whatever') it returns document.getElementById('whatever'), not window.whatever or document.whatever. So it's probably returning null. I don't use Prototype so could be wrong, but that's what their docs say. Edit: vvv Are you sure they're actually returning some element? Their docs explicitly state "nonexistent IDs will yield null". Remember that typeof null == 'object', so you'll have to examine it to see if it's really returning something. If it does return null you could take advantage of JavaScript's short circuiting operators: code:
Supervillin fucked around with this message at 16:20 on Apr 6, 2010 |
# ? Apr 6, 2010 02:21 |
|
Supervillin posted:Pretty sure Prototype will treat that argument as an ID, so if you try $('whatever') it returns document.getElementById('whatever'), not window.whatever or document.whatever. So it's probably returning null. That's the impression I got, too, but getElementById does return null while the dollar function actually returns an element. Edit: maybe the Prototype $() has to return something other than null since null wouldn't chain. Anyway, it's not a huge deal - just one of many ugly things. Munkeymon fucked around with this message at 15:03 on Apr 6, 2010 |
# ? Apr 6, 2010 14:59 |
|
Is there a more reliable way of finding the viewable pixel real estate than Prototype's viewport methods? I'm trying to make images shrink to fit the viewport but after a resize, the methods report the document dimensions instead of the dimensions of the window. Since HTML flows down like it's going out of style, I end up with wacky numbers for viewport height (ie bigger than my monitor) and pictures that flow off the screen given otherwise working resize code. This behavior doesn't seem to be entirely consistent since it was working fine at the end of last week in my tests and this morning the same tests are failing.
|
# ? Apr 12, 2010 15:46 |
|
Munkeymon posted:Is there a more reliable way of finding the viewable pixel real estate than Prototype's viewport methods? I'm trying to make images shrink to fit the viewport but after a resize, the methods report the document dimensions instead of the dimensions of the window. Since HTML flows down like it's going out of style, I end up with wacky numbers for viewport height (ie bigger than my monitor) and pictures that flow off the screen given otherwise working resize code. This behavior doesn't seem to be entirely consistent since it was working fine at the end of last week in my tests and this morning the same tests are failing. jQuery(window).height(); jQuery(window).wdth();
|
# ? Apr 12, 2010 16:26 |
|
Lumpy posted:jQuery(window).height(); I suppose reverse engineering that would be easier than trying to get jQuery to play nice with Prototype :\
|
# ? Apr 12, 2010 20:20 |
Munkeymon posted:I suppose reverse engineering that would be easier than trying to get jQuery to play nice with Prototype :\ Probably not! http://docs.jquery.com/Using_jQuery_with_Other_Libraries
|
|
# ? Apr 12, 2010 20:29 |
|
fletcher posted:Probably not! Oh nice - of course the test server just took a poo poo so I can't do anything with it but, hey, at least now I know.
|
# ? Apr 12, 2010 21:35 |
|
I posted this in the jQuery thread, but it hasn't seen any action in the last few days. Since it's related, I thought I might be able to post it here and get some useful feedback Using jQuery, I produced a long block of animations nested inside of each other with callbacks. It looks kind of ridiculous and it's already pretty terrible to make changes to it. Is there a more elegant way to write this? code:
|
# ? Apr 14, 2010 18:29 |
|
smug forum rear end in a top hat posted:jQuery If you just want to get rid of ugly nesting, I would stick each callback in a local variable like so: code:
|
# ? Apr 14, 2010 19:57 |
|
Couldn't you do something there with recursion, sending in different params each time?
|
# ? Apr 15, 2010 12:21 |
|
someone actually posted a stellar reply to the post in the jquery thread. i almost wish i hadn't cross posted, but both threads seemed pretty dead at the time
|
# ? Apr 15, 2010 15:57 |
|
Yeah that solution is a lot better than mine.
|
# ? Apr 15, 2010 17:49 |
|
I'm trying to write a function that when a user selects some text on a web page and then clicks a button, that text will be replaced with different text that is the result of another function. I've gotten to the point where I can grab the text that is selected when the button is clicked and perform the transformation on it, but I'm stuck on how I can then replace the selected text with the new text. Most of the examples I've found are done on text inside a <textarea>, but I want to do it on regular text on the page. Any thoughts?
|
# ? Apr 25, 2010 04:39 |
|
You can change the innerHTML of the parent object, or do complex stuff with document.createTextNode...
|
# ? Apr 25, 2010 09:52 |
|
edit: i obviously didn't read the question correctly
smug forum asshole fucked around with this message at 18:27 on Apr 25, 2010 |
# ? Apr 25, 2010 15:46 |
|
Sergeant Rock posted:You can change the innerHTML of the parent object, or do complex stuff with document.createTextNode... I guess more specifically the problem I'm having is how to reference the position of the selected text in order to replace it. The parent object could conceivably contain a whole lot of text and I want to replace single words or phrases, and doing a string replace on the word or phrase won't work since there could be multiple occurrences within the parent object and I only want to modify the selected one.
|
# ? Apr 25, 2010 18:06 |
|
I think NYT's website does something like that for word definitions when you highlight text. Maybe you could take a peek over there and see what's going on.
|
# ? Apr 25, 2010 20:42 |
|
|
# ? May 17, 2024 18:28 |
|
Alright, I'm trying to do a simple form validation for a drop box. I want it to give a "Hey choose something stupid" if the value is still "Select One" when the user clicks submit. With the current code, it allows the user to go to the next page regardless of what they choose in the dropdown box. I've tried several different javascript validators, but none of them seem to work with this.code:
code:
hasegawa fucked around with this message at 22:22 on Apr 25, 2010 |
# ? Apr 25, 2010 22:20 |