javascript

Getting RegExp result after being used in if-statement

I've seen people do the following: if (/Firefox\/(\+S)/.test(userAgent)) { firefox = RegExp.$1; } I know (sorta) what the regexp does, but I'm not really sure how it can be accessed with RegExp.$1. And as a side note: if (/Win(?:dows )?([^do]{2})\s?(\d+\.\d+)?/.test(ua)) { if (RegExp.$1 == "NT") { switch (RegExp.$2) { What'...

Using Javascript's LiveConnect functionality to access classes not in java, sun or netscape causes ClassNotFoundException

Hello, I am trying to access a class I wrote using JavaScript's Packages object, but I get a ClassNotFoundException. I am running Apache Tomcat 6, using Firefox 3.0.11 to view the content. Here is the class: package tests; public class testclass { public String str; public testclass() { str = "String from external clas...

stop settimeout in recursive function

Hello, my problem is that I can not stop a timer. I had this method to set a timeout from this forum. It supposed to store the identifyer in the global variable. By accident, I found out that it is still running after I hide "mydiv". I also need to know now, if the recursive function creates multiple instances or just one for the ti...

How to trap "open in a new tab" clicks in jquery.click

Good morning - I have a jquery script that attaches a click event to every link, running an action when the link is clicked. This has been working great, but I just got some betatester feedback that's foiling me. The user was right-clicking on the link and opening it in a new tab. When she did this, jquery didn't trap the click. BAD U...

How to chain ajax requests?

I have to interact with a remote api that forces me to chain requests. Thats a callback-hell in asynchronous mode: // pseudocode: ajax(request_object, callback) ajax(a, function() { ajax(b(a.somedata), function() { ajax(c(b.somedata), function() { c.finish() } }) }) It would be much more readable in sync mode: sjax...

Javascript in .ascx file

I have .ascx controls which I load on the page using renderpartial. I have need where in I want to hide some Div tag on the page where I am loading the control. I added a Javascript to the .ascx file, but it seems that it does not get included in the page and hence I cannot hide the DIV tag when I load the control. Any help?? ...

How to limit the duration time to finish an exam in my site

i want to limit time of exam in the site , after the time is finish , alert popup window with message and redirect the user to another page. the exam contain some pages , the user can turn pages forward and backwards. i want to prevent (how much i possible) to lie. ...

Rotate Images in Javascript

How can I rotate a set of images in an ellipse? how to get each point on a ellipse at some center(x,y)point. ...

Ajax function throwing WebServiceFailedException

I am using same asp.net page to edit and add data, only with some fields disabled and enabled accordingly. Now when I call webmethod from the add page, it's working fine, but when I call it from edit page, it is not. Though I am using the same javascript function to call the server side method. Please see the code: .aspx: function KeyCh...

IE7 question: under what condition the ActiveX warning appears?

I have two html files, but contains javascript. But wired enough, when I open one of them the ie7 displays it w/o any warning but the 2nd one always shows the warning message saying this file contains ActiveX/javascript bla, bla. I compare those two files, no difference. Anybody gets any clue? Thanks in advance! ...

Prevent IE from refreshing when keypress is handled

How can I prevent IE from refreshing when Ctrl-R is handled in the page by script? This also goes for things like opening the browser history, etc. The solution does not need to work in Non-IE browsers, but it must work in both IE 6 and IE 7. Is this even possible? ...

Left offset of an inline element using jQuery

I have the following piece of HTML: <div><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit ...

Catch browser's "zoom" event in JavaScript

Is it possible to detect, using JavaScript, when the user changes the zoom in a page? I simply want to catch a "zoom" event and respond to it (similar to window.onresize event). Thanks. ...

splitting string up

hi all, I have a string build up like varstring1_varstring2_id1_id2 eg: move_user_12_2 . I want to extract id1 and id2 out of the string. Since I'm a complete prototype beginner I'm having some troubles solving this. Thanks Stijn ...

Silverlight.createobject not working as expected?

Hi guys, I need some help with the createobject function in Silverlight. My xap file accepts a video url and loads it for playing. When I write a tag as follows, it works fine. <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%"> <param name="source" value="ClientBin/Vide...

Diff RegisterClientScriptBlock & RegisterStartupScript & responce.write("script")

Hi i need individual explanation and individual advantages regarding RegisterClientScriptBlock & RegisterStartupScript & responce.write("script"); i got some information like RegisterClientScriptBlock() methods will inject the script after the form open tag but before page controls RegisterStartupScript() methods will inject the s...

LRU cache implementation in Javascript

Java has LinkedHashMap which gets you 99% there to an LRU cache. Is there a Javascript implementation of an LRU cache, preferably from a reputable source, that is: understandable efficient (amortized O(1) get/put/delete) ? I've been searching on the web but couldn't find one; I thought I found one on Ajax Design Patterns but it glos...

Creating the Hidden Image in JavaScript

How to disable the image display for <img src =a.gif > tag ...

Is there a way to be notified by the DOM when an element is removed?

My initial research has come up empty and I am not sure if this is possible. I am looking for a solution using straight up javascript. I cannot use jQuery due to constraints of the device. Basically, I want to attach an event for when an element is removed and provide a function to execute. [EDIT] We do the DOM manipulation via a fun...

tracking pixel or javascript include?

Hi, I am building a tracking system for refererrals to our websites and on behalf of other 3rd party website owners. This will include placing a cookie when a customer clicks through to the site and subseqently reading their ID from this cookie if they reach the defined 'success' page. I have seen a number of different methods used fo...