javascript

Text Resizing with jQuery?

I found this great solution for on-site text resizing with jQuery: http://dev-tips.com/featured/jquery-tip-quick-and-easy-font-resizing Works like a charm, but their are three things it's missing that I need; A.) A 'return to default' click able option. B.) Limits on resizing (i.e. only allow it to be resized up or down twice C.) Addi...

Value passed from Javascript to Java through JavaScriptInterface not working

Why below code is throwing nullPointer exception in last line (when accessing javaInterface.mValue) This line through NullPointer, so basically it is not being set. even though the javascript is correct and has been verified using FireBug that it returns expected string. There are few lines above this code chunk but it is irrelevan...

Inverse of jQuery.extend(true, …)

I'm looking to reduce storage requirements for JSON data by deltifying it against a known set of defaults. Basically, what I want is an inverse for jQuery's .extend() function, such that the following test passes for arbitrary JSON-compatible objects: function test_delta(defaults, delta) { var current = $.extend(true, {}, defaults,...

how to assign a block of html code to a javascript variable (solved)

Hi, what is the syntax to store a block of html code to a javascript variable? <div class='saved' > <div >test.test</div> <div class='remove'>[Remove]</div></div> I want to assign the above code to a variable 'test' var test = "<div class='saved' > <div >test.test</div> <div class='remove'>[Remove]</div></div>"; but it does not w...

Loading content from a div from another website into an iframe on current page

I was able to get a full page loaded into an iframe but I want a certain part of the page. I know the div id of what I need. This is my current code onload=function(){ var el=document.getElementById("frameContainer") el.innerHTML = "<iframe src=\"url\"></iframe>" } I was thinking of getting the full page and then grabbi...

Protect website from Backdoor/PHP.C99Shell aka Trojan.Script.224490

My website was infected by a trojan script. Somebody managed to create/upload a file called "x76x09.php" or "config.php" into my webspace's root directory. Its size is 44287 bytes and its MD5 checksum is 8dd76fc074b717fccfa30b86956992f8. I've analyzed this file using Virustotal. These results say it's "Backdoor/PHP.C99Shell" or "Trojan....

Mint.com's awesome categorization widget

Mint.com has possibly the best category/subcategory control I've seen. It is a combination of autocomplete and a two-level menu - complete with keyboard support. Does something like this exist as a jQuery plugin or stand-alone javascript control? If not, what approach would you use to make one. It looks like they are using YUI. He...

Finding start and end tags in string using regex

I am trying to parse an HTML file ( non strict one) using JavaScript my output should be the same HTML file, but I need to process the internal content of any <script></script> tag. I have a method processScript(script) that does that.. I can assume that there will be no <script/> tags. I have a pretty clear idea how to it using just ...

File upload with temp iframe and Prototype event handlers

I'm working on a script that will submit form files (images) through a temporary iFrame and then return thumbnails of the images, which are then moved from the iFrame to the main document. This works fine. But I am also embedding a link which the user can click to remove the image if desired. This link uses Prototype to send a request to...

Javascript replace() regex by index number

I have the following string and regex: var string = "Dear [to name], [your name] has decided to share this [link]"; var patt = /\[+[A-Za-z0-9]+\]/; I want to be able to change each of the bracketed variables with dynamic input. How would I use match() or replace() to target the 1st, 2nd and 3rd occurrences of this regex? EDIT: At th...

Implementing Google Custom Search API through Greasemonkey

Hi everyone, I want to implement the Google custom search API with Greasemonkey, and so far my trials have met with mostly failures. The goal of the code is to inject a custom search box into an existing site (I'm trying to do this for MATLAB's documentation pages, but the injected code should really work with any site). I have attempte...

How do i open popup window in C# ASP.Net application for Chrome? (RegisterStartupScript not working)

I have the following line of code: ScriptManager.RegisterStartupScript(this, typeof(string), "print", "javascript:window.open('Print.aspx');", true); This opens up the popup window in Firefox and IE, but not Chrome. Normally, I would use onClientClick on the button, which works fine on all browsers. In this case, however, I have to do...

prototype js invoke with custom function

Hello all, I have an array of div names, the div of which I would like to switch off on loading. I read from both prototype api and another website that invoke is generally preferred if one is to do the same thing to each of the items in a list. //I have this switch_off function function switch_off(div){ Effect.SwitchOff(div); } ...

How to find all occurrences of one string in another in JavaScript?

I'm trying to find the positions of all occurrences of a string in another string, case-insensitive. For example, given the string: I learned to play the Ukulele in Lebanon. and the search string le, I want to obtain the array: [2, 25, 27, 33] Both strings will be variables - i.e., I can't hard-code their values. I figured that th...

How to read both single object & array of objects in json using javascript/jquery.

Hi, I wrote the json reader to read the data & works fine with the below data. {"menu": { "id": "file", "value": "File", "popup": { "menuitem": [ {"value": "New", "onclick": "CreateNewDoc()"}, {"value": "Open", "onclick": "OpenDoc()"}, {"value": "Close", "onclick": "CloseDoc()"} ] } }} but the when j...

JavaScript: Detecting/intercepting insertion of <img> into DOM

We're using a third-party analytics reporting script provided by this analytics company. It adds a 1x1 pixel image into the DOM with reporting data in the URL of the image. Is there any way for me to monitor the DOM and intercept this <img> element and change its "src" attribute before the browser requests the image? Sounds like a real...

Iframe and drop down

So I have an iframe on my site, on that iframe I have a menu, some links have a drop down list, now here is the problem, I can't see the drop-down because of the iframe height, is there a hack or something for this. I want the height of the iframe to stay the same, but the drop-down to display normally, over the content, I have positio...

javascript/jquery: looking for image-fading script

hi all, i'm looking for a lightweight script (pure javascript preferred) - it should be for smoothly fading a sequence of images into each other (=image-carousel). it should also be possible to run several instances (so it should be a prototype script), like for example: - site banner: fading 3 images after each other - main content: 3...

Problem with IE in customized javascript slideshow (nivo) on rollover

Hello everyone!~ I am using the fabulous Nivo Slideshow (http://nivo.dev7studios.com/) without problems throughout a website I am currently working on. However, for the slideshow on the homepage, I modified it to swap the image on rollover (in this case the swapped image is a black and white version of the same image). On rollover I also...

Buggy Behavior using Canvas?

I am making a game using html canvas. Here is my progress: http://db.tt/ei3LlR (use WASD and Left/Right Arrow keys) Helps to ZOOM. My questions are: Why does the shadow flicker in google chrome when the tank is turning? Why does the turret image flicker in safari when the turret is turning? Why does it work fine in Firefox? ...