javascript

Copy to clipboard in Javascript

Is there a way at all of altering the clipboard of the user via Javascript? I want it that they click a given point on a map and it adds the coordinates of the position to their clipboard. I do however assume that this is not possible for Javascript to achieve. ...

In firefox, how can I change an existing CSS rule

In firefox, I have the following fragment in my .css file tree (negative){ font-size: 120%; color: green;} Using javascript, how do I change the rule, to set the color to red? NOTE: I do not want to change the element. I want to change the rule. Please do not answer with something like ... element.style.color = 'red'; ...

javascript arrays and type conversion inconsistencies

I have been playing with javascript arrays and I have run into, what I feel, are some inconsistencies, I hope someone can explain them for me. Lets start with this: var myArray = [1, 2, 3, 4, 5]; document.write("Length: " + myArray.length + "<br />"); for( var i in myArray){ document.write( "myArray[" + i + "] = " + myArray[i] + "<...

Remove JavaScript comments from string with C#

I am trying to remove javascript comments (// and /**/) from sting with C#. Does anyone have RegEx for it. I am reading list of javascript files then append them to string and trying to clean javascript code and make light to load. Bellow you will find one of the RegEx that works fine with /* */ comments but I need to remove // comments ...

Hide/clear input field with prototype

Hy everyone, I have the following script : if (Object.isUndefined(Axent)) { var Axent = { } } Axent.SelfLabeledInput = Class.create({ initialize: function() { var labelSelector = arguments[0] || 'label'; $$(labelSelector).findAll(function(l) {return (l.readAttribute('for') !== null)}).each(function(l){ l.hide(); $(l.readAttr...

Greasemonkey: XPath returns no results for .xhtml page

When running on an xhtml page, xpath doesn't seem to return any results. var result = document.evaluate( "//a/img", document.body, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null ); For example returns an empty result set. What's the problem here, and how do I fix it? ...

Are there any WYSIWYG HTML editors that don't mess up the code?

I've tried various editors, both desktop applications and web-based RTEs, but have not found anything that works very well. All too often, they mess up code, adding in "tag soup". Even the ones that claim to only produce valid code often produce a total mess of span tags and style attributes. Here are some of the features I'm looking fo...

Creating a textarea with auto-resize

There was another thread about this, which I've tried. But there is one problem: the textarea doesn't shrink if you delete the content. I can't find any way to shrink it to the correct size - the clientHeight value comes back as the full size of the textarea, not its contents. The code from that page is below. I'd appreciate any help or...

Javascript Onclick Problem with Table Rows

Hello. I am having problems with my JScript code. I am trying to loop through all of the rows in a table and add an onclick event. I can get the onclick event to add but have a couple of problems. The first problem is that all rows end up getting set up with the wrong parameter for the onclick event. The second problem is that it o...

Is it possible to load a javascript ad last on the page to prevent slow load times?

Is there a way to include a javascript-loaded advertisement last on the page, but have it positioned in the content? The primary purpose is to keep the javascript ad from slowing down the page load, so if there are other methods to achieve this please do share. ...

What's a good way to store model data in a jQuery app?

I'm working on a web app which is heavy on the client side, which is a first for me. I'm also using jQuery for the first time. I need to have my client-side code keep track of model data which it fetches via Ajax calls. What's a good way to store this data? Does jQuery provide a good solution, or is there a good generic Javascript so...

How to display youtube-like video player in website?

I'm working on a website where I want camera-recorded vidoes to be uploaded, and be viewable (but not downloadable) to logged-in users only. I'd also like to edit the videos, have certain images appear in the background, and possibly note the time at which they last stopped watching a video. (I.e if they stopped watching after 30 mins, i...

Passing cookie data between iframes

Say I have a website, www.example.com, with a login box which sits in an iframe situated in api.example.com. My question is: Is it possible to pass cookie data from the inner iframe (api.example.com to the website, so the website knows when the user logged in? Is it possible to do this client-side, without the need to refresh the whole...

events for nested elements

I am using the listen plugin for jQuery for binding events to dynamically created elements. In my scenario, I have a div hosting a span element. I want function "spanClicked" to fire on span click and function "divClicked" to fire on div click when I click on the div to fire function "divClicked", since the span is inside of it, funct...

What is better: CSS hacks or browser detection?

Commonly when I look around the Internet, I find that people are generally using CSS hacks to make their website look the same in all browsers. Personally, I have found this to be quite time consuming to find all of these hacks and test them; each change you make you have to test in 4+ browsers to make sure it didn't break anything else....

How to grey out the full browser window and display a form in the center?

Have you come across those websites that grey out the full browser window and show you a notification or ask you to fill in a survey .. etc? This used to happen with myspace, if you mistyped in the email or password the full browser window would grey out (it's transparent though, you still can see the contents of the page through it) and...

Is it possible to create a javascript User-defined function in sqlite

BACKGROUND: Firefox 3 includes SQLite version 3.5.9. Firefox also allows extensions, which are written in javascript and can call the embedded SQLite engine. As expected, executing the following SQL statement 'SELECT "TEXT" REGEXP "T*";' gives an error, since there is no REGEXP function natively included in SQLite. javascript include...

how do i check if an object has a key in javascript ?

which is the right thing to do? if (myObj['key']==undefined) or if (myObj['key']==null) or if (myObj['key']) Exact duplicate of: http://stackoverflow.com/questions/135448/how-do-i-check-to-see-if-an-object-has-an-attribute-in-javascript ...

setTimeout () moving div with iframe causing flicker in firefox only

I have a horizontal scroll created in javascript that works in IE and Chrome, however I get a flicker in Firefox 2 and 3. The div that is moving contains an iframe with images and text with absolutely positioned divs. (see code below.) Problems: 1) The content appearing in either the div to the left or the right of the animating d...

JSON datetime between Python and JavaScript

I want to send a datetime.datetime object in serialized form from Python using JSON and de-serialize in JavaScript using JSON. What is the best way to do this? ...