javascript

Validating output from one or more document.write

I have a form that accepts javascript which allows the use of document.write() and I want to validate the output of the javascript which may look like this: var a = 'book1'; var b = 2; document.write("</scr"+"ipt>"); document.write("<scr"+"ipt type='text/javascript'src='http://www.example.com/loader.js?mydoc="+a+"&amp;page="+b+"'&gt;")...

Prompt User before browser close?

We have an administrative portal that our teachers constantly forget to download their latest PDF instructions before logging out and/or closing the browser window. I have looked around but can't find what I'm looking for. I want to accomplish the following goals: Goal 1 Before a user can close the browser window, they are prompted "...

Regions/code collapse in Javascript in Visual Studio 2010

Is it possible to create code regions in JS files in Visual Studio 2010? This method works in 2005, but I can't get working in 2010. ...

contenteditable element prevents hyperlink default behavior

I've got the following problem. In IE if a contenteditable element is nested inside a hyperlink, clicking on the element prevents the hyperlink default behavior, i.e. navigation to another document. In FF it works fine. How can I solve the problem? Just removing the contentEditable attribute is not a solution since I want this behavior (...

Creating a json obj from a string when working without a net connection?

Hi, I have a json object returned from a third party api, it looks like: {"version":"1.0","encoding":"UTF-8"} I'm going to be working on my project without a network connection, so I have to do everything locally. How can I create an instance of a json object locally for testing? Say I copy the above string, can I do something like: ...

Reserved word 'script' embedded in id tag - id can't be referenced

This is a new one on me. In FF 3.6.3, use of the word 'script' in a tag id seems to make the id return null when searched on with document.getElementById. Thus document.getElementById("blah_script") returns null from <div id="blah_script"></div>. Understood that 'script' in general is a reserved word, but I didn't know it was so spook...

Get an array of forms in java script using prototype

My document contains more than one forms. How can I get an array of all forms using prototype? <html> <head></head> <body> <form id="form1"> <!-- Other stuffs here --> </form> <form id="form2"> <!-- Other stuffs here --> </form> <form id="form3"> <!-- Other stuffs here --> </form> </body> </html> ...

If Statements Skipping or Evaluating Strangely, JavaScript and jquery

So in jQuery, I have a global variable "currentSubNav" that stores a current visible element. The following code executes on "mouseenter". I need it to get store element's ID, check to see if there was one. If there wasn't, set the new visible element to the default. $('#mainMenu a').mouseenter(function() { var newName = $(this).at...

Uncaught Error: INDEX_SIZE_ERR

I am drawing on a canvas with the following line: ctx.drawImage(compositeImage, 0, 0, image.width, image.height, i, j, scaledCompositeImageWidth, scaledCompositeImageHeight); This code has executed error free on Safari, Chrome, Firefox (and even IE using google's excanvas library). However, a recent update to Chrome now throws the fol...

How to automatically expand html select element in javascript

I have a (hidden) html select object in my menu attached to a menu button link, so that clicking the link shows the list so you can pick from it. When you click the button, it calls some javascript to show the <select>. Clicking away from the <select> hides the list. What I really want is to make the <select> appear fully expanded, as i...

Does video tag (HTML 5) injection via JavaScript work in any browsers?

I'm trying to dynamically spawn a video element on a page using JavaScript. JavaScript <script type="text/javascript"> $(document).ready(function() { var video = $(document.createElement('video')) .attr('id', 'VideoElement') .attr('controls', 'controls') .attr('src', 'videopath.mp4') // Changed 'href' attribute to '...

How to print a stack trace in NodeJS?

Does anyone know how to print a stack trace in nodejs? ...

jQuery slideToggle Hide / Show Issues

I am having a couple problems trying to manually insert some jQuery features into a wordpress theme. I have a lightbox wordpress plugin that is jQuery based that is working fine. So if I manually load the jQuery script into wordpress the functions seem to work but instead of say a slide being hidden it is revealed when it should still ...

How to clear Lookup field in MS Dynamics CRM 4.0 using JavaScript

I'm trying clear the value of a lookup field via Javascript. I've tried this: crmForm.all.new_mylookupfield.DataValue = null; But that isn't working. I inspected the DataValue of the lookup when it was in fact cleared and it returned a null. alert(document.getElementById("new_mylookupfield").DataValue == null); // true I'm must be ...

How can I clear content without getting the dreaded "stop running this script?" dialog?

In Windows Forms there's a BeginUpdate/EndUpdate pair on some controls. I want something like that, but for jQuery. I have a div, that holds a div. like this: <div id='reportHolder' class='column'> <div id='report'> </div> </div> Within the inner div, I add a bunch (7-12) of pairs of a and div elements, like this: <h4><a>Hea...

open window with dynamic content

Is it possible to open a window from PHP that has predefined content? It's obvious how you can open a window from a javascript link that frames an existing page, or just do a target=_blank from a regular a tag that references an existing page. But I am generating a bit of content, and want that content to be opened in a new link (or stre...

how to create plots (non-flash) with mouse-over info boxes on the fly for the web?

Hi, I'm thinking about creating a tool to visualize scientific data on a website. For this, the user enters some query string and out comes a simple (x,y)-plot (similar to this) I know that using Matplotlib, one can generate graphics on the fly for python. However, this doesn't solve the need for some custom java-script code to display...

Have a child window be notified when parent window goes to a different page?

i have a parent window and a child window. in javascript, i want a function in child window to be called whenever the parent window loads a new page. i'd like to use something similar to jQuery's $(document).ready() so that I don't have to worry about whether the parent is done loading yet - but ready() only appears to fire when the wind...

Facebook Connect and Hash Password Encryption

I'm trying to integrate a Zen Cart site with Facebook Connect. So far, I've been able to get Zen Cart to recognize that the user has a facebook account and is logged in, but that's it. True authentication into Zen Cart eludes me because I can't figure out where a password could be stored and how to get it to Zen Cart to be compared with ...

Replace images in a DIV using JavaScript

I want to show different images in a DIV, the turn of an image depend on a random number. The image name is like 1.gif, 2.gif, .. 6.gif to do that I coded var img = document.createElement("IMG"); img.src = "images/1.gif"; document.getElementById('imgDiv').appendChild(img); but it does not replace the old image how ever it add an anot...