javascript

JAVASCRIPT: Count the number of REGEX results

This is what regex should find { anything in it }, and then I want to count the number of results what the regex found. So I have a string like this: {example1}{example2}{example3} in this case the count number is 3 ...

Handling image-heavy web pages

I have a list of TV shows which is about 200 shows long. Each of these shows has a little image, 40x60 pixels and 3 kB, and they are all listed on the same page at the same time. Now I'm starting to think that maybe it's not such a great idea to have about 200 requests to the server each time the page is being viewed. What is the best ...

JAVASCRIPT: Make array from regex

I have this string: {example1}{example2}{example3} This is the regular expression to find these { anything in it }: /\{.*?\}/g Now I want to know how put them in an array so I can do a FOR IN statement. EDIT I want an array something like array("{example1}","{example2}","{example3}"); ? ...

Google Search Injection

Hi I'm writing a chrome extension to inject information into google search results. The only problem is that searching is now done through ajax instead of http. This means my code is only being executed once. This is a problem because my script needs to render on each new page. The only way to make it work is by refreshing the page manua...

jquery Return Random Value from array.

So this should be a relativly easy thing for most people but I'm having trouble with it. I'm using the jquery validate plugin and would like to return a random vaule on success. Right now I'm trying to use. var success_message = new Array (); success_message[0] = "Good!"; success_message[1] = "Ok!"; success_message[2] = ...

access parent url from iframe

Okay, I have a page on and on this page I have an iframe. What I need to do is on the iframe page, find out what the url of the main page is. I have searched around and I know that this is not possible if my iframe page is on a different domain, as that is cross-site scripting. But everywhere I've read says that if iframe page is on t...

How do I get the referrer's domain/host name using javascript?

I know I can get the host name of the current page, by simply doing: var myhostname = location.hostname; But how do I get the host name of the referrer? I can get the referrer by var referrer = document.referrer; but unfortunately there's no document.referrer.hostname available in javascript. Any ideas how I can get this value? An...

Dynamic Links and jQuery Lightbox issue : Loading image in lightbox...completely stumped!!

I have a function that dynamically creates links for a photo gallery. The function also produces a larger image as a background image of a div when and thumbnail is clicked on. What I want to do is have a third event, where if the user clicks the enlarged image in the div, the jQuery Fancybox loads an even bigger version of the image bei...

Difference between undefined and not being defined in Javascript

See http://jsfiddle.net/FDhQF/1/ for a trivial example. What's the difference between something being undefined and something not being defined in Javascript? For instance, trying to access a property for an object (effectively, trying to access a variable) that isn't defined will return undefined. But you can also set something = undef...

Using window.opener.location to access a non-secure (http) opener from a secure (https) pop up

I am opening a popup which is under https from a web page which is under http. When I try to use the command window.opener.location.(href/str/port/domain.. etc) from the pop-up to get the url of the opener page, I get a 'Permission Denied'. Ive also been using Firebug on Firefox to test this out. Is there any way I can by pass this by us...

how to do the regexp in javascript for this string?

Hi there: I have the following possible string: '', or '4.', or '*.4' or '4.35' all the above format are valid, others are all invalid. basically, if I don't care the digit or word character, this is what I used in PHP for the validation: else if ( !ereg('^\*|.*\..*$',$bl_objver) ) Now, I would like to add some clientside...

textbox validation

how to get all text box in loop for validation to check all like if (textbox.text == "",textbox2.text == "",textbox3.text == "") { textbox.Focus(); } ...

write data in json format to js file?

Hi, I am thinking of this idea: 1. Request data from server and write to javascript file in json format using C# 2. When the page loads, the page loads the js file and I can use the data using javascript? is this a good or bad idea? is there any example somewhere doing that? thanks ...

Resolving conflict between multiple jQuery files

I have multiple jquery files in my project. I am using facebox using jquery1.4.2 but i need prototype and scriptacolous scripts too. I have used jQuery.noconflict(); in my code but its not working. this is the url http://mlep.com/~avalon/wordpress/ideas-and-insights/case-studies/. ...

Wordpress - Disqus error with custom page template

Hi, I created a custom page template to display a filterable portfolio in Wordpress. However, on that custom page I am getting an error code - // <![CDATA[ (function() { document.write('<script charset="utf-8" type="text/javascript" src="http://thinquetanque.disqus.com/get_num_replies_from_wpid.js?v=2.2&amp;amp;t=span&amp;amp;wpid0=14&...

change color on hover

Hi! I have buttons and they change colors when they are hovered. But I am trying to make a button remain with a changed color after being hovered until another button is hovered. I read a post and it said to use a:focus but this is an implementation that works only when clicking a button, not with mouseover thing. Any help appreciated....

cloneNode does not clone the value of file upload elements in Google Chrome.

I have been using cloneNode in Firefox and it is working fine. But in Chrome it doesn't work as I expected. The cloneNode method does clone the node but it doesn't clone the value of the node if the node is file(<input type="file">). Anyone know how to fix this problem? ...

Highlight text in specific position with jquery

I want to highlight text in a specific position. Something like this: highlight with jquery, but it only highlights the word in the position n. For instance, highlight only the second hello in the text "hello, hello, hello" Thank you ...

HTML5 Canvas: Zooming

Hello. Is there any easy way how to zoom in and back out in canvas (JavaScript)? Basically I have a 400x400px canvas and I'd like to be able to zoom in with 'mousedown' (2x) and go back with 'mouseup'. Spent last two days googling, but no luck so far. :( Thanks for help. ...

balancing a scale

Hey guys i have a formula the percentage of cals_in vs cals_out (out of 200%) i created a scale to show the difference in the values in terms of percentage. The problem is I wanna convert the difference in terms of pixels height to move the scale up or down function setScalesToValue(fValue) { document.getElementById("cals_in").styl...