|
Avenging Dentist posted:Look at the number of quotation marks in this (underlined for emphasis): Thanks for the help. Should I get rid of those quotation marks or replace them with a different character? I tried removing them and the links did not work. Also, I don't know how to assign an ID to the links like I did the buttons, so if you could help me with that I'd appreciate it. Here's what it looks like in context. I'm really pleased with the results. http://www.noapparentfunction.com/experimental/
|
# ? May 22, 2009 19:54 |
|
|
# ? Jun 5, 2024 08:53 |
|
noapparentfunction posted:Thanks for the help. Should I get rid of those quotation marks or replace them with a different character? I tried removing them and the links did not work. Also, I don't know how to assign an ID to the links like I did the buttons, so if you could help me with that I'd appreciate it. You can use single quotes if you like. Also, adding an ID to an "a" tag is exactly the same as adding one to a "button" tag: id="butts". As usual, each ID must be unique on that page.
|
# ? May 22, 2009 19:57 |
|
I can't figure out why the result would be i = 0:code:
|
# ? Jun 2, 2009 22:54 |
|
Munkeymon posted:I can't figure out why the result would be i = 0: Because you have i set up as a global. Because you didn't use this or var in front of it. code:
Lumpy fucked around with this message at 23:08 on Jun 2, 2009 |
# ? Jun 2, 2009 23:04 |
|
A variable declared without the var keyword is global.
|
# ? Jun 2, 2009 23:06 |
|
Let me preface this by saying I am not a Javascript programmer in any way. It's been almost a decade since I touched it seriously, and in that time the language (and paradigm) have changed enough to make whatever I did remember almost useless. With that said, I'm wondering if one of you guys can help me with a Greasemonkey script. The short version is that I'm trying to find a way to delete certain elements on the Facebook homepage (specifically, I want to get rid of "Highlights" items from people whom I don't care about.) The proof-of-concept works fine either using getElementsByClassName() or jQuery. The problem comes in the fact that Facebook uses some AJAX'ified way to load pages. When you click a link it doesn't send you to a new page, it (so far as I can tell) uses some Javascript to fetch and the new page's data, erases the current page data and replaces it with the new data. Effectively, it's loading new pages without ever having to actually load a new page. This is a problem because Greasemonkey scripts run when a page is loaded. If it never detects the page is reloaded, the script never runs. The effect is that my script works great when you first go to facebook.com, since that's a normal load, but if you click a link and then click a link back to the homepage, my script is completely oblivious because FB is 'cheating' on the load, and my script is never run, and the homepage is rendered unmolested. Do any Facebook users now what/how I can hook whatever function it uses to load new pages to then trigger my script? One lead I'm investigating is that FB seems to load some new iFrames on each cheater load, and those do trigger my script (though it then senses that the page being loaded, being simply a hidden data frame, isn't the homepage and then gives up.) Is there an easy way to maybe make my script, triggered inside an iFrame, 'break out' of the iFrame and then run on the containing page?
|
# ? Jun 3, 2009 03:35 |
|
Since you are creating a GM script (hence, developing this for Firefox only) you can use the DOMSubtreeModified or DOMNodeInserted events to signal the deletion script.
|
# ? Jun 3, 2009 05:07 |
|
ronin109 posted:Since you are creating a GM script (hence, developing this for Firefox only) you can use the DOMSubtreeModified or DOMNodeInserted events to signal the deletion script.
|
# ? Jun 3, 2009 07:04 |
|
Does anyone know of a multiple select javascript code that works with Prototype JS core? I don't want to use any other add on libraries like livepipe and I don't particularly want to roll my own.
|
# ? Jun 3, 2009 15:23 |
|
Lumpy posted:Because you have i set up as a global. Because you didn't use this or var in front of it. Fucks sake. I promise I'll stay home when I'm sick next time.
|
# ? Jun 3, 2009 15:52 |
|
I'm making a nice website for a mobile library project in the Peruvian Andes, I tried to use javascript to make the forms easier to fill out and then I realised I don't have a clue what I am doing This does what I want in firefox (adds/removes another row from the table) but it doesn't work at all in IE. Can someone fix it for me? Cheers. http://new.bibliotecaurubamba.com/iesucks.htm code:
FrozenShellfish fucked around with this message at 07:34 on Jun 8, 2009 |
# ? Jun 7, 2009 20:58 |
|
FrozenShellfish posted:I'm making a nice website for a mobile library project in the Peruvian Andes, I tried to use javascript to make the forms easier to fill out and then I realised I don't have a clue what I am doing It appears to work fine in ie 8.
|
# ? Jun 7, 2009 21:18 |
|
FrozenShellfish posted:I'm making a nice website for a mobile library project in the Peruvian Andes, I tried to use javascript to make the forms easier to fill out and then I realised I don't have a clue what I am doing It'd be worth your while to check out jquery - using it you could probably reduce this down to a few lines of code as well as making it more cross-browser compatible.
|
# ? Jun 9, 2009 07:09 |
|
Hey. I have an XML request which gives me a list of data. An older version of these data already exist on the webpage. Both data are variants on a simple list. What's the best way of syncing these lists? In the HTML list, each item is in its own div, and the XML nodes from the new list are being looped through. The method I can think of at the moment, is to remove all old (HTML) items from the new (XML) list. If an item isn't found in the XML list, it's removed from the HTML. At the end, all the remaining items in the XML are added to the HTML div list. This poses data structure problems, and I'm not familiar with how best to handle lists in javascript. Would arrays be the way forward?
|
# ? Jun 12, 2009 21:16 |
|
Fruit Smoothies posted:Hey. I have an XML request which gives me a list of data. An older version of these data already exist on the webpage. Both data are variants on a simple list. What's the best way of syncing these lists? In the HTML list, each item is in its own div, and the XML nodes from the new list are being looped through. Performance-wise it seems like it would be much faster to just replace the whole list than to sync using two or possibly three loops through each set. Maybe I'm too tired or something, but wouldn't you get the same data if you destroy the HTML list and add all the XML items? Edit: If I DID misunderstand, either Arrays or object literals should work fine. Those are pretty much the only list paradigms built into JavaScript. I know ExtJS and probably some other libraries have ways of binding data sets together, might be what you need. Editx2: vvv Just need more semantic markup and you should be all set. Make your list a real list (ul/dl), or if that's not feasible at least surround the list with a container div that can be reset without affecting the forms and images after the list. Supervillin fucked around with this message at 01:38 on Jun 14, 2009 |
# ? Jun 13, 2009 06:42 |
|
Supervillin posted:Performance-wise it seems like it would be much faster to just replace the whole list than to sync using two or possibly three loops through each set. Maybe I'm too tired or something, but wouldn't you get the same data if you destroy the HTML list and add all the XML items? The trouble is, there are other elements tree'd under the list items. These contain forms and images which empty and flicker if the HTML is re-written. The list updates about every second.
|
# ? Jun 13, 2009 11:29 |
|
Quick question... how do I stop the onBeforeUnload event from popping up its default question window (aside from not returning anything in the callback function)?
|
# ? Jun 16, 2009 15:36 |
|
Why are you listening for beforeunload events, if not to potentially stop the document unloading? Could you listen for unload instead?
|
# ? Jun 16, 2009 15:49 |
|
I need to have the user decide whether they want to save data on a webapp before navigating away. I wanted to use my own confirm window so I could capture what button was clicked. Is there a way to capture the button clicked on the default beforeunload event popup?
|
# ? Jun 16, 2009 16:21 |
|
The only way to see which button the user pressed is to test whether the unload event follows the beforeunload event. Browsers deliberately restrict the author's choices in this scenario, and always display a standardized UI for the close-tab confirmation dialog, because they don't want to let malicious sites confuse users about the basic mechanics of navigating and closing/opening windows. I guess this is partly fallout from the well-established tradition of making banner ads or popups look like system dialog boxes, to fool users into clicking or obeying them.
|
# ? Jun 16, 2009 16:41 |
|
0zzyRocks posted:I need to have the user decide whether they want to save data on a webapp before navigating away. I wanted to use my own confirm window so I could capture what button was clicked. Is there a way to capture the button clicked on the default beforeunload event popup? Gmail seems to manage this - if you try and leave it before data finishes loading it presents you with a prompt that allows you to stay with the page even though you've requested to leave it. Good luck making sense of viewing their source though!
|
# ? Jun 18, 2009 03:01 |
|
0zzyRocks posted:I need to have the user decide whether they want to save data on a webapp before navigating away. I wanted to use my own confirm window so I could capture what button was clicked. Is there a way to capture the button clicked on the default beforeunload event popup? So, you don't want to prevent them from leaving, but you want to prompt them to save before leaving, right? How about this? code:
|
# ? Jun 18, 2009 06:03 |
|
I have this in my CSS:code:
code:
I just want the element to be invisible on page load and visible after a function is called.
|
# ? Jun 19, 2009 17:26 |
|
Jreedy88 posted:I have this in my CSS: Set the display to block. Think "none" = invisible, "block" = visible
|
# ? Jun 19, 2009 17:30 |
|
Lumpy posted:Set the display to block. Yay! Worked like a charm. Thanks.
|
# ? Jun 19, 2009 17:48 |
|
Jreedy88 posted:Yay! Worked like a charm. Thanks. FYI, when you set it to "" you're telling it to set display to whatever its default is, which according to your CSS is "none"; that's why it seemed like it didn't do anything. Often when you come across snippets that hide/show stuff they'll use display="none" to hide it and display="" to show it, because the default could be "inline", "block", etc. depending on the element.
|
# ? Jun 20, 2009 09:25 |
|
Supervillin posted:FYI, when you set it to "" you're telling it to set display to whatever its default is, which according to your CSS is "none"; that's why it seemed like it didn't do anything. Yeah, block formatting messed my page design anyways so I ended up just doing a display="none" on the element in javascript after the page had loaded. Jreedy88 fucked around with this message at 16:25 on Jun 26, 2009 |
# ? Jun 26, 2009 15:14 |
|
Jreedy88 posted:Yeah, block formatting messed my page design anyways so I ended up just doing a display="none" on the element in javascript after the page had loaded. The answer to your disappeared question is to use "new Date()" instead of just "Date()", fyi.
|
# ? Jun 26, 2009 16:40 |
|
I've been working on a Firefox extension, and I'm having trouble with a particular javascript function.code:
I have tried multiple combinations of document.getElementById(image id).value and .src with combinations of the above image options (document.write("http://url.com/Smileys/sa/" + sreq.responseText) and a direct url like "http://url.com/Smileys/sa/goonpatriot.png") and neither seem to work. The part of overlay.xul in particular is correct as far as I can tell, but posting it just in case: code:
Never mind, fixed. Going to write "I shouldn't be using document.write to concatenate strings" 100 times on the blackboard Synter fucked around with this message at 12:49 on Jun 27, 2009 |
# ? Jun 27, 2009 11:53 |
|
I'm having trouble amending this javascript form submission to also allow the "Enter" key to submit the form. I'm not that experienced with javascript, so my googling has not been resulting in any successes at inserting the additional elements. my form currently checks a text area entry against a list of promotional codes before passing the user along to the next page, what I need it to do is to accept both pressing the 'go' button as well as hitting enter to submit the promotional code, so if anyone could explain to me how to do that I'd really appreciate it. My form: code:
code:
|
# ? Jul 7, 2009 18:28 |
|
Ether Frenzy posted:I'm having trouble amending this javascript form submission to also allow the "Enter" key to submit the form. I'm not that experienced with javascript, so my googling has not been resulting in any successes at inserting the additional elements. First link from a Google for "javascript bind keys" has a pretty good tutorial: http://www.javascriptkit.com/javatutors/javascriptkey.shtml
|
# ? Jul 7, 2009 18:52 |
|
Thanks for that tutorial link - didn't actually get my problem solved but having looked over that site some more, I'm learning more about JS now than I...uh, really wanted to know. But I did eventually get my script tweaked using googled results that plugged into my existing form validator... Here's what did the trick: code:
|
# ? Jul 7, 2009 20:51 |
|
Ether Frenzy posted:Here's what did the trick: A-are you seriously doing validation on the client side?
|
# ? Jul 7, 2009 21:26 |
|
Avenging Dentist posted:A-are you seriously doing validation on the client side? Seems fine to me if it's there to complement existing server validation.
|
# ? Jul 7, 2009 21:50 |
|
Ether Frenzy posted:I'm having trouble amending this javascript form submission to also allow the "Enter" key to submit the form. I'm not that experienced with javascript, so my googling has not been resulting in any successes at inserting the additional elements. Shouldn't it work just to make your input button type="submit"?
|
# ? Jul 7, 2009 21:52 |
|
royallthefourth posted:Seems fine to me if it's there to complement existing server validation. Yeah, I don't think "putting the list of valid (presumably secret) codes in Javascript" counts as "complementing server validation".
|
# ? Jul 7, 2009 21:56 |
|
By default, a form will be submitted whenever a form field has focus and the user presses the enter key so there is no need to recreate that functionality. The proper way to handle client-side validation is by using the form's onsubmit event. If the form fails validation you simply return false to cancel the form's submission. Returning true (actually, by not explicitly returning false) will cause the form to submit. The main problem with your current approach of listening for key events on the document is that pressing enter anywhere on the page (outside your form) will cause your form to be validated and submitted. What you really should do is use a submit button and do your validation (refcodecheck) in the onsubmit. However, all of this is moot if you actually intend to do (presumably secret) reference code checks since, as Avenging Dentist points out, that should be a server-side only check to avoid putting the "secret" answers in the source code of the page.
|
# ? Jul 8, 2009 05:37 |
|
ronin109 posted:However, all of this is moot if you actually intend to do (presumably secret) reference code checks since, as Avenging Dentist points out, that should be a server-side only check to avoid putting the "secret" answers in the source code of the page. Secret-code validation done on the client side would make a pretty good captcha for a programming website though.
|
# ? Jul 8, 2009 05:49 |
|
Avenging Dentist posted:A-are you seriously doing validation on the client side? Tell me about it. I wanted to do serverside validation with PHP but the location of the program is outside our boundaries, and the clients (and my bosses) were happy with the total lack of security. I let them know that this was not the real way to do this, but they didn't care. Which is why I ended up hacking up some JS to function here. The promo codes are freebie giveaways anyway, that are all virtually the same, but we wanted the illusion that they're original. Fundamentally security wasn't that high a priority with the sponsors, they were more interested that the users are passed through to the part where they spend money. Kilson posted:Shouldn't it work just to make your input button type="submit"? You can't do a satisfactory image replacement of the submit button (or at least not have it work in IE 6, which we stupidly continue to support - would typically be done with CSS v2) with input type="submit", it has to be input type="button" to use an image as the button. Which generated all this additional nonsense anyway.
|
# ? Jul 8, 2009 18:22 |
|
|
# ? Jun 5, 2024 08:53 |
|
Full disclosure - I posted this in the Web Design & Development small questions thread, but came to the conclusion that it's really more Javascript and I will be more likely to get help with it here. Hence I'm reposting it. My website implements a board game via PHP. A user can view a game in progress by visiting a URL that looks like mywebsite.com/board.php?GameID=1234. Although the site is essentially set up to enable a play-by-email kind of experience, it might happen that some users would like to play in real time, or close to real time. Because the page generated when visiting the URL is static, they can only see what the real current state of the game is by refreshing the page. This is inconvenient, and it means more work for my website too if people are constantly refreshing pages, so I rigged up a hack to slightly reduce the problem. To each game there corresponds a number saying how many moves have been made in the game. So it starts off at zero and is incremented whenever someone makes a move. If a user loads a page corresponding to a game in progress, then a Javascript runs such that every five seconds the page checks with the website to see if the number of moves made is bigger. If it is then it turns the page background a different colour, so as to alert the user without interrupting any activity the user is performing on the page. My <body> tag looks like this: <body onLoad="IntervalID = setInterval ('ajaxFunction()', 5000);" onUnload="clearInterval(IntervalID);"> For completeness, here is ajaxFunction: (This was taken from the page from a game that at the time had had 95 moves made, hence the "95") code:
onUnload="clearInterval(IntervalID);" This does not solve the problem. The page still changes colour sometimes when one leaves. What should I do to stop this?
|
# ? Jul 8, 2009 19:42 |