javascript

Internet Explorer 7 returns 'undefined' from jQuery class selector

I have a small JavaScript function that (among other things) retrieves the ID of the last element with a certain class name. var lastRowID = $(".sectionRow:last").attr('id'); It should find elements in a table that looks similar to the following: <table> <tr id="courseSection[0]" class="sectionRow"><td>stuff</td></tr> <tr id=...

Simulate onclick event problems in chrome

Hi. I'm trying to simulate onclick event in a h:commandButton when I close my browser. Here is my code: <body onBeforeUnload='closingBrowser()'> function closingBrowser() { document.getElementById('main:commandButtonHidden').onclick(); return false; } This javascript function call the function associated with my button whi...

jquery function is not a function

Hi! I'm trying submit some form using ajax //include jquery-1.4.2.min.js var submitForm = document.createElement("FORM"); ... jQuery.post(submitForm.getAttribute('action'), submitForm.serialize(), function(data) { bla-bla }); But there is error : "Error: submitForm.serialize is not a function" (FF) What can I do? Thanks. ...

getElementsByTagName() behaves differently in IE and FF.

I am new to JavaScript, trying to figure out a tag information value. GWT Code is as follows.. public static native boolean isToolBarInstalled() /*-{ alert("Validating the toolbar installed."); var metas = document.getElementsByTagName('head')[0].getElementsByTagName('meta'); var i; alert ("Meta length: "+metas....

jquery problem?

im trying to turn this jquery script into a toggle event type, thier is my script, with illustrations, to show what i want to happen. i cnt seem to intrgate it so here goes: //myElement.toggle(vote(), unvote()); // this is the toggle event $(document).ready(function() { $('.statuses').delegate('.vote_up', 'click', funct...

Javascript Plugin Development , Extending Libraries

i got two javascript objects api and myApi : var api = {}; api.foo = function(){ ... }; api.foo2 = function(){ ... }; var myApi = {}; myApi.foo = function(){ ...}; myApi.myFoo = function(){ ...}; myApi.myFoo2 = function(){ ...}; i want to add all myApi.* functions to api object without overriding api.foo. Indeed, i want learn how to...

How can you check if your document is opened in an IFrame?

Is there a way to know if your page is opened inside of an IFrame? An idea I had was to see if the window object has a .parent property, but this apparently is also true of standalone windows which are opened by Javascript's window.open() function. ...

Remove element when it has a specified child element

How can I delete list element if it has a child link of some defined id ? So looking at the code below I'd like to find a <li> with <a> of id=link1 and delete this li. <li class="nav-tab"> <a href="#link1">Component</a> </li> I've tried the code below but it doesn't work : $(function() { $('.nav-tab:has(#link1)').css('displ...

How can you tell if a user choose not to install a plug in?

Hi all, I am not sure the user is going to install the plug in. They can choose not to install. I need to know information like, install complete, or the user choose not to install. Any ideas? Thanks, Grae ...

How to find out the actual event.target of touchmove javascript event?

I am trying to develop a simple drag/drop UI in my web application. An item can be dragged by a mouse or a finger and then can be dropped into one of several drop zones. When an item is dragged over a drop zone (but not yet released), that zone is highlighted, marking safe landing location. That works perfectly fine with mouse events, bu...

Changing HTML page Icon?

I have a webpage. I want to change the icon on button down (this would be enough for me to understand but I'd be glad if you'd describe a way to animate icon after button click). ...

doesNotUnderstand for JavaScript?

Is there a way to simulate Smalltalk's doesNotUnderstand or Ruby's method_missing in Javascript? ...

simpletip help with dynamic content loading

I am trying to load content from the database using simpletip. My code: <script type="text/javascript"> $(document).ready(function(){ $('a.regularsList').simpletip({ onBeforeShow: function(){ this.load('/regulars/tooltip', {id: $(this).attr("id")}); } }); }) I get that i...

Retrieve Images From Server via Client Side

Hello StackOVerflow, I have a folder on the server with some images in it. I would like to have my client code read this folder's contents (images) and then display this image on a div. I thought this would be easy with AJAX, but it seems that AJAX returns some raw data embedded in the image. I have been looking all over for a way to...

JavaScript Design Patterns -- Dealing With Unwanted Asynchrony

I'm pretty new to event-based programming (using node.js). I believe that there's something I'm just not grokking about it, because there's a particular problem that I keep coming across again and again and again. In short, that problem is dealing with asynchronicity when it seems to be getting in your way. This most often manifests it...

Is there a way to wrap all JavaScript methods with a function?

I want to wrap every function call with some logging code. Something that would produce output like: func1(param1, param2) func2(param1) func3() func4(param1, param2) Ideally, I would like an API of the form: function globalBefore(func); function globalAfter(func); I've googled quite a bit for this, but it seems like there's only ...

disable a link in IE9 - prototype stop() not working

IE9 is still in Beta, but all the same, here is a question: Using prototype.js 1.6.1, proper form for adding a click event to a link, and override the default link behavior, would be: mylink.observe('click', function(e){ doSomething(); e.stop(); }); While this works perfectly in every other browser that I tried, IE9 is a unique...

JavaScript setAttribute vs .attribute=

Hello! Is there a best-practice indication about using setAttribute instead of the dot (.) attribute notation? e.g. myObj.setAttribute("class","nameOfClass");      - and - myObj.className="nameOfClass"; OR myObj.setAttribute("id","someID");      - and - myObj.id="someID"; etc Thank you. ...

Persisting textbox value using jQuery

I'd like to save the newly entered values, so I could reuse them. However, when I try to do the following, it does not work: // el is a textbox on which .change() was triggered $(el).attr("value", $(el).val()); When the line executes, no errors are generated, yet Firebug doesn't show that the value attribute of el has changed. I tr...

Question about hyperlinking a Javascript Object

I can make the button appear after 5 seconds. I'd like to be able to click the button and go to a different site (like google.com, for example). Help please? <style type="text/css"> #buy_button_image { display: none; } </style> <script type="text/javascript"> window.onload = function() { var img = document.getElementById("buy_button...