|
rt4 posted:I'm trying to keep track of the URL of a frame on my page. Is it possible to do this with JavaScript? If you want to get the URL after a change in the src, to make it cross browser compatible, I think you have to use DOM methods, not jQuery methods. Try this: code:
|
# ? Feb 1, 2010 19:31 |
|
|
# ? May 17, 2024 15:34 |
|
Thanks for posting that; looks like I can just use DOM methods with name instead of id like inside.location
|
# ? Feb 1, 2010 20:38 |
|
rt4 posted:I'm expecting toString() to tell me what's available in that object, but I just keep getting [Object object] Not sure, but the next thing I would try is alert($("#inside").attr('src'));
|
# ? Feb 1, 2010 22:29 |
Lets say I have an element and I use onmouseover and onmouseout to toggle the visibility of another smaller element that is to appear on top it. I'd like for the smaller element to remain visible when the mouse moves over the smaller element. Of course this currently is not the case, since it fires the onmouseout on the main element when I mouse over the smaller element. What is a good solution to this? edit: In case I explained that terribly, I found an example. In gmail, when you are viewing an email and mouse over the green name of the person who sent it, a little box pops up to email/chat/etc that user. When you mouse off the name, if box disappears. If you mouse off the name (and on to the little popup), the popup does not disappear. It seems like I could get it behaving the way I want with a timer, that way I can detect if they mouse off the element and on to the popup. Is there a different approach? fletcher fucked around with this message at 02:59 on Feb 5, 2010 |
|
# ? Feb 5, 2010 02:48 |
|
If the element you are binding the hover event to is a parent of the smaller element then you'll always be hovering the parent element even if it's inside the smaller element. That said unless the smaller element is 100% contained (visibly on the screen) you should still use the setTimeout trick so that if the mouse goes outside the parent element's visiblity while moving between inner elements you don't lose your the popup.
|
# ? Feb 5, 2010 03:20 |
supster posted:If the element you are binding the hover event to is a parent of the smaller element then you'll always be hovering the parent element even if it's inside the smaller element. Ah, I guess that was my issue. The smaller element wasn't actually a child, they were siblings, since the "main" element was an img. Using setTimeout seems to work great. Thanks for your input!
|
|
# ? Feb 5, 2010 03:42 |
|
If the smaller element was a child, it would still count as a mouseout when you moved the cursor onto the smaller element. This is what jquery's hover event is for, and why jquery is awesome.
|
# ? Feb 5, 2010 09:42 |
|
fletcher posted:Lets say I have an element and I use onmouseover and onmouseout to toggle the visibility of another smaller element that is to appear on top it. I'd like for the smaller element to remain visible when the mouse moves over the smaller element. Of course this currently is not the case, since it fires the onmouseout on the main element when I mouse over the smaller element. What is a good solution to this? Look at stopping event propagation / bubbling.
|
# ? Feb 7, 2010 12:20 |
|
dizzywhip fucked around with this message at 21:52 on Nov 9, 2020 |
# ? Feb 8, 2010 05:11 |
|
mit_senf posted:Is there a way to have an event fire when the browser's vertical scrollbar appears? Not technically, but there are ways to manually check. code:
Note hasVerticalScroll() will return true if there SHOULD BE a scrollbar, but depending on your CSS one may never actually show up. I'm assuming that won't be an issue in your case but prolly something to keep in mind.
|
# ? Feb 8, 2010 09:39 |
|
dizzywhip fucked around with this message at 21:53 on Nov 9, 2020 |
# ? Feb 8, 2010 10:43 |
|
mit_senf posted:The first case is when the page is short enough before images are placed on the page so that there's no scrollbar, but afterwards the images make it long enough for a scrollbar to appear. Do you have control over the content that gets loaded? If you can assign width and height styles to each image, they'll be properly sized on append, rather than waiting until they load. Slightly messier, once the tab contents are replaced you could add an onload to each image that will check the tab size / scrollbar issue again. But I'd only do this if I don't have control over what images are loaded, meaning I wouldn't necessarily know what size they are during coding. No idea about the second thing, sorry.
|
# ? Feb 8, 2010 17:08 |
|
dizzywhip fucked around with this message at 21:53 on Nov 9, 2020 |
# ? Feb 8, 2010 20:26 |
|
I'm just starting out learning some Javascript, and run into this problem that's just driving me nuts:code:
Why can't I access the div tag through myForm.elements? The reason I don't want to use document.getElementById is the page is generated dynamically from rows in a database, one form for each returned result. By passing the form associated with the button I can avoid having to name the elements 'target1', 'target2' .. 'target99' etc. I've seen other people do it this way, but it really rubs me the wrong way So, for each form the <DIV>'s will all have the same name. (The button will submit updates via AJAX, and I'm using the DIV tag to output the response.) Doing it this way works fine for the textboxes. It's just those DIV tags that won't listen to common sense. Am I missing something obvious? Or going about this completely the wrong way?
|
# ? Feb 12, 2010 18:52 |
|
gently caress it, man. Get jQuery.
|
# ? Feb 12, 2010 18:54 |
|
I do not think you are supposed to have multiple elements with the same id attribute. I would probably try to throw xpath at it or something and match on a div with a certain class within the form.
|
# ? Feb 12, 2010 19:13 |
|
Divs aren't part of the form.elements collection - only form fields and fieldsets count. Get the DB to output an incremented id on each div, and use getElementById, like you're supposed to. You're also using some hideously outdated HTML and JS there.
|
# ? Feb 12, 2010 21:29 |
|
JasonV posted:I'm just starting out learning some Javascript, and run into this problem that's just driving me nuts: Wherever you are learning your js from, stop. As said before, use jQuery, or if you want to do it the "hard" way to learn the under the hood stuff, learn HTML first.
|
# ? Feb 12, 2010 23:33 |
|
Also, that div doesn't need an ID at all, duplicated or unique or anything. DIV is a tag name.code:
Try the definitive guide, there's a ton of good info in there, even though it's from 2006. And Head First is a good one for starting out with HTML/CSS, along with why you may or may not want to use XHTML (your code currently uses both, which means it's incorrect either way). Supervillin fucked around with this message at 01:18 on Feb 14, 2010 |
# ? Feb 14, 2010 01:03 |
|
Thank for the advice all. I think I pretty much knew I had jumped too far ahead and was doing it all wrong, but just needed someone to stick my nose in it
|
# ? Feb 14, 2010 23:12 |
|
This site claims that using square brackets is faster than eval. (Actually I think that's pretty well known) However, I can get eval to work but not using the bracket method. I'm passing a value through a function to point to a given input box name that triggers after you type. This works: code:
code:
LP0 ON FIRE fucked around with this message at 21:18 on Feb 18, 2010 |
# ? Feb 18, 2010 21:09 |
|
awdio posted:This site claims that using square brackets is faster than eval. (Actually I think that's pretty well known) However, I can get eval to work but not using the bracket method. I'm passing a value through a function to point to a given input box name that triggers after you type. They don't do the same things at all. Try: code:
|
# ? Feb 18, 2010 21:18 |
|
Sorry, I didn't mean to leave the "eval" in there in the 2nd example. Anyway, OddObserver, your example works. Thanks!
|
# ? Feb 18, 2010 21:20 |
|
JasonV posted:Thank for the advice all. I think I pretty much knew I had jumped too far ahead and was doing it all wrong, but just needed someone to stick my nose in it Here's what it should look like (Mootools specific but the principles don't differ much from jQuery, really). code:
Your site.js file looks like this (again, Mootools-specific!) code:
If you would be making something that would pop up images in a lightbox, the advantage of adding JS afterwards is that you could just add hyperlinks directly to the image, such as: code:
code:
Laserjet 4P fucked around with this message at 21:46 on Feb 18, 2010 |
# ? Feb 18, 2010 21:41 |
|
I am trying to call a function once AJAX loads it's response. This function uses variables set by the script AJAX runs, so I don't believe it is accessible via readystate. I can, however, make it run onclick at the same level it should run onload. I have tried window.onload (which I realize is useless at this point), document.getElementById("div_id").onload (where the div is only present from the called script's results) and putting it between <script> tags standalone before and after the <div> to be updated. Is there a standard way of doing this or am I just done for unless I can stick it in the readystate?
|
# ? Feb 19, 2010 00:03 |
|
awdio posted:Sorry, I didn't mean to leave the "eval" in there in the 2nd example. Anyway, OddObserver, your example works. Thanks! Please tell me there's a good reason that transVideoCopyToCopies isn't just an array.
|
# ? Feb 19, 2010 00:06 |
|
Lou Ferrigno posted:I am trying to call a function once AJAX loads it's response. This function uses variables set by the script AJAX runs, so I don't believe it is accessible via readystate. I can, however, make it run onclick at the same level it should run onload. I developed a workaround by including the script ajax calls directly in the div initially. Then, when it gets updated, it changes the div like normal. The problem is that I had to set a variable in the AJAX post data that tells the file to include all of my functions as they are lost when the div is updated. by including it directly initially, it either would "re-declare" them all again, or when updated would "fail to call" because they were wiped clean after the ajax call. This seems like a patch job and I hope that there is a way to load a js function automatically w/o an onload or onclick function. Lou Ferrigno fucked around with this message at 05:17 on Feb 19, 2010 |
# ? Feb 19, 2010 05:10 |
|
I opened a window using window.open. I pass in the argument scrollbars and set the value to either yes or no. I am now in the child window. My javascript is running. I want to know if the window has scrollbars enabled or not. How do I do this? - I am in IE so window.scrollbars/this.scrollbars won't return anything - The windows scrollbars exist outside the body. - Looking at the document's width will tell me about the document. I can even figure out if there are scrollbars in the document. This will not tell me anything about the window itself. - The width of the scrollbar in question changes Dependant on what the currently selected Windows Desktop Theme is, for ascetic reasons. edit: To be perfectly clear - I need to know if the application has scrollbars, not if the body's overflow has a scrollbar. I need this information to call window.resize. Both the application's scrollbar and the little bar on the left of the application window that lets you resize it are taken into account with window.resize. Just looking at the html inside it isn't enough. I need to know the expected width of the application window itself for this to work right. diadem fucked around with this message at 21:11 on Feb 23, 2010 |
# ? Feb 23, 2010 19:00 |
|
Has anyone seen this? js.Fiddle It looks like a pretty neat tool for posting snippets of html/js/css to share and debug.
|
# ? Feb 24, 2010 08:45 |
|
Avenging Dentist posted:Please tell me there's a good reason that transVideoCopyToCopies isn't just an array. On the php portion of the page there's X amount of transVideoCopyToCopies fields. So, in a For I just call it "transVideoCopyToCopies".$i document.fmf['transVideoCopyToCopies' + fieldNum].value is just referencing a name of a field in php... I don't see why it would have to be an array if that's what you're asking.
|
# ? Feb 26, 2010 19:38 |
|
I don't know if this deserves it's own thread or not but, drat this is dangerously clever http://sla.ckers.org/forum/read.php?24,33349,33405 http://discogscounter.getfreehosting.co.uk/js-noalnum.php
|
# ? Feb 26, 2010 21:55 |
|
Question: Why is the document null? window.html code:
code:
|
# ? Mar 5, 2010 06:15 |
|
The document parameter inside DivWindowObject is undefined because you are not calling the function with any arguments. The windowTitle, width, height, xOrigin, and yOrigin parameters are all going to be undefined too, for the same reason It looks like maybe you are calling the .show() method with those arguments instead of DivWindowObject itself. Or maybe you are trying to access the global document variable, in which case you need to rename your local document variable to something else.
|
# ? Mar 5, 2010 06:50 |
|
Nigglypuff posted:The document parameter inside DivWindowObject is undefined because you are not calling the function with any arguments. The windowTitle, width, height, xOrigin, and yOrigin parameters are all going to be undefined too, for the same reason Okay, I'm dumb. Sorry. I can't believe I missed that. I've been fixing code all day and was trying to make something to make my life easier and I screwed up. HFX fucked around with this message at 07:54 on Mar 5, 2010 |
# ? Mar 5, 2010 07:43 |
|
One of my pages has a setInterval that gets called in the onload property of the <body> tag: <body onLoad="IntervalID = setInterval ('ajaxFunction()', 20000)"> As you can see this is supposed to go off every 20 seconds. The purpose of ajaxFunction() is to check on the contents of a small .txt file on the site to see if they have changed, and if they have changed, to notify the user by changing the page background colour. I have determined that it works as expected. However, I noticed while using the Firebug "Net/XHR" tab that the function appears to get called less frequently than specified. It seemed to happen about every two minutes or thereabouts, instead of every 20 seconds. Then I closed Firefox and started it up again, as my browsing session had been going on for a while, and timed the delay another time. This time it was about 35-45 seconds. If you are logged out when you visit the page, then the delay is set as 180,000 milliseconds instead of 20,000. I visited the page logged out and timed the delay between requests again, and found it was about 9 minutes. This is weird, why might my interval be so much longer than I specified?
|
# ? Mar 5, 2010 16:44 |
|
I don't know if it would help if you'd fix it, but your setinterval is wrongly defined.code:
edit: to clarify it's not wrong per se, but not very good practice. karms fucked around with this message at 00:03 on Mar 6, 2010 |
# ? Mar 5, 2010 23:58 |
|
KARMA! posted:Thanks for the pointers, I changed my syntax slightly to be more standardised.
|
# ? Mar 6, 2010 15:25 |
|
trying to make a slidedown menu type thing, using this: http://andylangton.co.uk/articles/javascript/jquery-accessible-show-hide/ but with images not text. I've managed to do it, but the problem is that the menu is fine on initial load, the showtext menu button displays fine, then when it it is clicked down drops the menu fine, but once clicked, the button reverts to <img src='images/news.png'> rather than the actual png file. It continues to function fine, but the image won't display, just the code. code:
|
# ? Mar 9, 2010 13:40 |
|
Boring posted:jQuery toggle Code while forgeting about proper HTML I just mangled with your code a bit (used other pngs for local testing). Switching to a different method to change the image did the trick. Substitution from text in "" or '' with variables is something you figured out anyway. code:
|
# ? Mar 9, 2010 16:30 |
|
|
# ? May 17, 2024 15:34 |
|
Boring posted:trying to make a slidedown menu type thing, using this: You are setting the text() of the element, which will treat whatever you stick in there as... text! You want to set the html() of the element, which will treat what you stick in there as HTML, and show the image. Also, you are using multiple elements with the same ID. This makes baby web-developer jesus cry. Don't do that. Lumpy fucked around with this message at 17:03 on Mar 9, 2010 |
# ? Mar 9, 2010 16:54 |