javascript

Partial Accordion with preview text

I need to develop a way to show and hide text sort of like an accordion but able to still have a preview of it available like: Preview Version: I am an instruction that will help guide you.... Full Version I am an instruction that will help guide you on your way towards happiness. ...

ASP.net ListView, EditTemplate + JQuery UI Sortable. Triggers EditTemplate on wrong ListView item.

I'm trying to implement .sortable on a ListView, with a few problems. Using this event I save the order of the elements: $('#sortable').bind("sortupdate", function (event, ui) { var array = $('#sortable').sortable("toArray"); $.ajax({ type: "POST", url: "../Resources/WebServices/MailTemplateCategory....

How to resize DIV with its component using Javascript

Dear All, I have created a html page of two DIV with tab component using jquery. Tab component is resizable and have min/max width. There is a scrollable divider between DIV. But the problem are the components of the div, which are not resizing according to the resized div position, it is overlaping on the other div. Any suggestion o...

HTML5 drop event child prevented

I using HTML5 D&D. I have one "parent" drop area, e.g. "parent". In that parent I drop my childs, e.g. "child". Each dropped child become also dropped area, e.g. it could accept D&D events. If I dragging something over "parent" area, it highlighted, same for the "child" areas. But I face issue, that "drop" event, fires from "parent" are...

Is there a general mechanism to timeout events in node.js?

I am learning node.js and most of examples I can find are dealing with simple examples. I am more interested in building real-world complicated systems and estimating how well event based model of node.js can handle all the use cases of a real application. One of the common patterns that I want to apply is let blocking execution to time...

Loading an image to a <img> from <input file>

I'm trying to load an image selected by the user through an element. I added a onchange event handler to the input element like this: <input type="file" name="picField" id="picField" size="24" onchange="preview_2(this);" alt=""/> and the preview_2 function is: var outImage ="imagenFondo"; function preview_2(what){ globalPic = n...

Check if javascript is enabled in browser

I have this code which checks if js is enabled and redirects: <noscript><meta http-equiv="refresh" content="0;url=http://www.domain.se/act.html"&gt;&lt;/noscript&gt; However, I wonder if this is SE friendly... This because I have added my website url to yahoo recently, and instead of the title appearing in the search results, the tex...

Scoping issues in javascript classes

The classical programmer in me is in love with the public/private paradigm of OO and I am finding it very hard to give up. This has caused me to run into an issue I was hoping you can help me with. I have a singleton object called map. There can be only one. This map contains objects called Star (it's a game). A Star looks like this: ...

Cross domain cookie using CORS in Safari

I followed the example: http://arunranga.com/examples/access-control/credentialedRequest.html from this page: http://arunranga.com/examples/access-control/ The example work in Firefox, but not Safari, anyone have tried in implementing CORS cross domain cookie handling, and being success in Safari? Thanks. ...

Call function from parent

Page A has iframe B. In iframe B, I have a var store a function name of page A. How to call that function from iframe B? (Both in a same domain) I try this in iframe B eval("window.parent." + func_name + "('"+param1+"', '"+param2+"');"); It work well but I ask for a better solution if possible. ...

Drawing a circle on the canvas using mouse events

I am trying to draw a circle using mouse on the canvas using mouse events, but it does not draw anything: tools.circle = function () { var tool = this; this.started = false; this.mousedown = function (ev) { tool.started = true; tool.x0 = ev._x; tool.y0 = ev._y; ctx.moveTo(tool.x0,tool.y0); }; this.mousemove = function (ev) { var center...

Save selected part of web page as text file using Javascript

I have a web page with few tabs. All tabs have same data but in different format. The page has a copy to clipboard feature which copies the contents of the active tab to clipboard. Similarly we need to have a save as text file option which copies contents of the active tab alone by prompting use for selecting a location and then ssving i...

JS listener for global var?

I want to keep everything contained within a single function, and not make all the various variables global. Is it possible to set up an event listener within the function main to watch a global var? in this example call doTheStuff() when the index is altered? or might I be going about this the wrong way? var index = 0; function mai...

Return from closure?

How does one return from a closure, without returning from the containing function? In the following function, the return statement actually returns from GM_xmlhttpRequest: not the closure. Naturally I can see that I could arrange my code so that that execution drops off the end of the closure, but I'm curious as to how to early return ...

Call javascript method defined in parent from iframe

After some research (even at stackoverflow) I still can't figure out how to do this. parent.method() won't do the trick, nor some other solutions I've tried. Situation: I have a index.html on the client side (mobile phone in this case) which has an iframe loading server-side page. What I need to do is call a javascript method defined i...

iframe across domain get value

How can I get the some value from other domain page? for example two page from different domain test.html: code: <!DOCTYPE html> <html> <head> </head> <body> <div> <span id="data"></span> <iframe name="dd" src="http://otherdomain.com/innerpage.html" style="width:600px;height:500px;"></iframe> </div> </body> </html> innerpage.htm...

Javascript: clearTimeout seems to only suspend, not reset or clear?

I am very new to JS and am trying to modify the JavascriptKit jQuery-based megamenu system to delay showing the menu until the mouse has been hovering over the anchor object for a specified time. The problem I am facing right now is that it seems that the clearTimeout that is called on mouseout only suspends the setTimeout, rather than ...

Toggle TWO Drop Down Panels

I am using two panels at the top of my web page that drop down: "Fast Quote" and "Client Login". Can someone show me how to alter my code so that ONLY ONE panel is open at one time? Example: If "Client Login" is open and the user clicks on "Fast Quote", the "Client Login" should close and the "Fast Quote" drops down. Here is my webs...

JavaScript to PHP visitor trackers

Can anyone explain how javascript trackers (like the code that Google Analytics and Click, etc have you put on your page), work? I'd like to build my own and I'm fine with the PHP side of things, its just getting the data from a remote page with javascript that I'm unsure of. ...

How to detect if my site is in Facebook iframe or standalone site

I want to programatically detect if my site is within the Facebook iFrame app so I can display certain features specifically for Facebook. Otherwise if someone goes site without Facebook. Preferably an FBML, C# or JS solution would be great :) Thx! ...