javascript

finding location of HTML elements with javascript & offsettop

I'm trying to find the location of an element on the screen using javascript. This is what I'm doing. function locateTargets(){ var targets = document.getElementsByTagName("span"); for(var i = 0;i<targets.length;i++){ if(targets[i].className == "target"){ targetsY[targets[i].getAttribute("id")] = targets[i].o...

adobe air and window.close()

Hi all. I have a simple task to do but I reall don't know how to do this. I created Full screen Adobe Air application which does window.location='http://example.com to external page just in a tag. The problem is that I can't close Air application from that page using window.close(); - just doesn't work. If I load http://example.com into ...

How do I stop the browser from scrolling to the top when an "#section" link is clicked.

I have the following link: <a href="#section">Section</a> Now I really want this link to be working so the url will be changed to mypage.html#section But than on the other hand, if I just keep the code as it is, the browser would scroll the page back to the top automatically, and I don't want that to happen. Obviously return false...

What is the easiest way to pass multiple variables in JQuery?

I have a form that uses a JQuery Json post. I have 10+ textboxes on the page. I have variables passed the only way I know... is there another way to pass multiple variables? $('#nameSubmit').click(function() { var status = document.getElementById('Select2').value; var lob = document.getElementById('LOB').value; var lName =...

Problem with Opacity in IE

Hi there. I have a simple href that calls a javascript function that makes a div hidden and shows another one instead of it. Then I'm using javascript to put in some nice fade-in effect. It works fine in Firefox and chrome. On IE I had to use width: 100% to make it work. And tho it's working now, it totally ruins my font type. Here's the...

ClearInterval() won't stop my rotate function

I'm using the jQuery Rotate plugin, to animate the rotation of an image 90 degrees, and then stop the rotation. My problem is that it won't stop rotating, even after calling clearInterval(); $(document).ready(function() { var finalAngle; var intval = setInterval(function func() { $("#myimg").rotate(1); if(type...

How to validate for save but not for delete?

Here is a snippet of my form <form action="" method="post" onsubmit="return verify()"> <input type="submit" name="submit" value="Delete" /> <input type="submit" name="submit" value="Save" /> </form> As you can see I am verifying with a function called verify(). I only want to verify if they click "save", I do not want ...

Data empty in jQuery.get() callback

$.get("http://localhost/test.php", (function(data){ alert(data); })) The alert is empty. I'm new to this, and I can't see what I'm doing wrong. Help? ...

Page not loading in IE

I just made some CSS changes to a page and all works perfect in firefox safari, chrome but when i view it in IE there is nothing. I mean just a blank page http://posnation.com/pos_support/aldelo_training_dvd Also this is a miva site ...

how to reverse e.preventDefault() from the body?

I have this: function dontMove(event) { // Prevent page from elastic scrolling event.preventDefault(); } & <body ontouchmove="dontMove(event);"> This, on the ipad, stops it from being draggable and does not allow that grey background the ipad has when you drag a whole page around to show up. I have seen on another website ...

How can I hide or show a div based on if there is content in two textboxes using jQuery?

I have 2 textboxes on a page and they both have the class "OrderEntry". I want it so if there is any text in either of of these textboxes, it will show the div with ID "OrderPanel". If the textboxes are cleared, backspaced or empty, it will hide the div "OrderPanel". So, the page loads, "OrderPanel" is hidden and both "OrderEntry" tex...

ExtJS panel does not render properly unless I open Firebug - WTF?

I have the following ExtJS Panel embedded in another Panel, which then resides in a TabPanel and the TabPanel is in a FormPanel. With that being said, these start/end date fields are initially displayed in very small cells -- the cells are so small that I see horizontal scroll bars. Now here's the weird part: if I open Firebug, everyth...

What is "i" in "function(i)" in the following JavaScript?

In the following code there is "function(i)", but "i" hasn't been declared anywhere previous to this statement. ul.css({width: 10, overflow: 'visible'}).retarder(100, function(i){ i.css('visibility', 'visible').animate( {width: ul[0].wid,left:-50}, {duration: 500, complete : function(){ ul.css('overflow', 'visi...

Can I override jQuery .val() for only some input elements?

Suppose I'm using a "placeholder" jQuery plugin that reads the "placeholder" attribute from input elements and simulates it for browsers that don't yet support placeholders. But I would still like $("input").val() to work properly -- that is, to return "" if the text in the textbox is the placeholder text. Is there anyway I can overrid...

jQueryUI Accordian Menu - How to deal with items with no sub-menus

I've got a vertical menu using jQueryUI's Accordian method. The first two items have sub-menus and then the rest don't. I also have the event set to 'hover' instead of 'click'. The problem: is that when you hover over any of the items with no sub-menus, then it hides the one with a sub-menu. Is there a way I can make it so it always k...

flexible drag/drop with jquery (like this javascript)

I'm trying to understand how this drag/drop javascript example would be done in jquery. I'm guessing the jquery version will be cleaner, more efficient, and easier to understand. ...

Is it a bad practice to reference Javascript objects from DOM elements?

As a "best practice" for front-end developers, is it bad to use the "control" property to reference back to the Javascript object? Here's a link to the property in question: https://developer.mozilla.org/en/XUL/Property/control I've seen a lot of Javascript functions that reference DOM elements using selectors and then perform DOM mani...

javascript how to add textboxs' values and titles to textarea

I have this html: <input type="radio" name="r1" value="v1"><input name="asd1" title="text1" id="asd1"><br> <input type="radio" name="r2" value="v2"><input name="asd2" title="text1" id="asd2"><br> <input type="button" name="but1"> <textarea rows=6 cols=80 name="conclus" id="idConclus"> </textarea><br><br> Is there a way on js to fill ...

Cross browser compatibility; Website appears strange in IE browsers

I am starting to test my website in different browsers. So far Firefox is ok, Chrome is ok, Opera is ok. Now I am starting on IE. First off, why are all my divs dispositioned in IE? How can I solve this? Do I need to hack and check what browser visitor has? Secondly, how come it seems as if my website looks the same (like crap) in IE6...

RegEx for three letters and two numbers

Hi! Two quick questions: What would be a RegEx string for three letters and two numbers? I.E "LET 12" ? And so I don't bother you guys in the future, would you happen to know any good RegEx resources/tools? EDIT: There will be space before and after the 'LET 12', sorry I forgot to mention that! :) ...