javascript

SVG repaint

I'm working on drawing an SVG grid using Javascript. I've managed to get the axis drawn, as well as my quadrant labels. However I've run into an issue adding my dynamic points. I'm trying to draw the points in the onload event of the SVG element. When using Firebug I have been able to confirm that the circle elements representing my poi...

Changing textarea wrapping using javascript

For my small wiki application, I mostly need to have the textarea used to edit the contents to use soft (or virtual) wrapping. However, in some cases, not wrapping the content would be preferable. I thought I would do this by simply having a button to turn off wrapping. Here is the simplified code: <form name="wikiedit" action="[[scri...

How can I convert a string to boolean in JavaScript?

Can I convert a string representing a boolean value (e.g., 'true', 'false') into a intrinsic type in JavaScript? I have a hidden form in HTML that is updated based upon a user's selection within a list. This form contains some fields which represent boolean values and are dynamically populated with an intrinsic boolean value. However, o...

How can I get a list of the differences between two JavaScript object graphs?

I want to be able to get a list of all differences between two JavaScript object graphs, with the property names and values where the deltas occur. For what it is worth, these objects are usually retrieved from the server as JSON and typically are no more than a handful of layers deep (i.e. it may be an array of objects that themselves...

Detecting clicks inside an iframe from outside?

Here is the scenario. There is content loaded in iframe from other site. I click to some link inside the iframe. Is it possible to catch somehow outside the iframe what is that link? UPDATE Since I recieved question if my intentions are pure, I would explain more on the use case. May be I started in wrong direction for this task. So,...

How can I get Javascript debugging to work with my ASP.NET MVC application?

I can't seem to get Javascript debugging working for my ASP.NET MVC application even though I can for a traditional ASP.NET WebForm app. I have followed the steps for unchecking the 'Disable Script Debugging' boxes for both IE and other. when I add a simple function to display an alert in both the site.master and any content view the b...

Hiding DIV does not work properly in Opera

My code works great in IE8, Firefox and Safari. But it doesn't work properly in Opera. What happens is that the DIV is hidden but the space occupied by the DIV remains to appear in my web-page. <div style=" z-index:-1;height :380; width:760; position:relative; text-align:center" id="new-add"> <object id="banner-flash" classid="clsi...

How to find the cookie blocked using java script code

How to find the cookie blocked using java script code ...

Does the onchange event propagate?

I'm using event delegation to listen for events lower in the DOM, but it's not working for an onchange event on a select box. Does the onchange event propagate or bubble up the DOM? Googling has failed in finding a conclusive answer. ...

Would an automatic MSIL to JavaScript conversion be useful?

I've been working on a project called Axial that converts MSIL (compiled C# or VB.NET) to JavaScript. There are a few samples of working code, but some common situations don't work properly. (The current release doesn't work in production mode and the SVN code doesn't work in debug mode but is much cleaner.) I've heard from quite a few p...

Can I use a VB variable inside of an Embedded Javascript section?

Is it possible to do something like this: <% Dim foo as string = "bar" %> <script type="text/javascript"> var baz = <%=foo %> </script> Where the <script> tag is embedded on my index page? ...

Refactoring a function that uses window.open to use the DOM rather than write()

I have an application that uses window.open() to generate dynamic popups. Unfortunately, I've had trouble creating the content of the new windows using the standard DOM functions (createElement, appendChild), and I've gone to using document.write() to generate the page. Concretely, how can I go from this: function writePopup() { va...

preventDefault() on an <a> tag

I have some html/jquery that slides a div up and down to show/hide it, when a link is clicked: <ul class="product-info"> <li> <a href="#">YOU CLICK THIS TO SHOW/HIDE</a> <div class="toggle"> <p>CONTENT TO SHOW/HIDE</p> </div> </li> </ul> and my jquery... $('div.toggle').hide(); $('ul.product-info li a').click(...

What is the best field validation plugin for Prototype?

Not wanting to re-invent the wheel or anything, I was wondering if there's a plugin out there a field or form validation plugin that works with Prototype that you can recommend from your own experience and why? ...

How do you raise a server-side event from javascript?

I have a control that is basically functioning as a client-side timer countdown control. I want to fire a server-side event when the count down has reached a certain time. Does anyone have an idea how this could be done? So, when timer counts down to 0, a server-side event is fired. ...

How to redefine CSS classes with Javascript

Let's say we have defined a CSS class that is being applied to various elements on a page. colourful { color: #DD00DD; background-color: #330033; } People have complained about the colour, that they don't like pink/purple. So you want to give them the ability to change the style as they wish, and they can pick their favourite ...

Reading the value of an input using XPath, then using in Greasemonkey

Hi - I'm using this XPath to get the value of a field: //input[@type="hidden"][@name="val"]/@value I get several results, but I only want the first. Using //input[@type="hidden"][@name="val"]/@value[1] Doesn't work. Once I have this, how do I pick up the value in Greasemonkey? I am trying things like: alert("val "+val.snapshotItem...

Prototype click, mouseover and mouseout can't work together?

Hi, I'm trying to do a very simple button that changes color based on mouseover, mouseout and click, I'm doing this in prototype and the weird thing is if I used mouseover and mouseout, after I clicked on the button, the button wouldn't change to white, seems like it is because of the mouseout, here's my code $("izzy").observe('mouseove...

how to detect if a URL points to a SWF

Is there a way (preferrably using JavaScript) to determine whether a URL is to a SWF or a JPG? The obvious answer is to sniff the filename for ".jpg" or ".swf" but I'm dealing with banners that are dynamically decided by the server and usually have a lot of parameters and generally don't include an extension. so i'm wondering if I co...

What's the best way to replace links with JS functions?

A pattern that's started to show up a lot in one of the web apps I'm working are links that used to just be a regular a-tag link now need a popup box asking "are you sure?" before the link will go. (If the user hits cancel, nothing happens.) We've got a solution that works, but somehow we're a web app shop without a Javascript expert, ...