javascript

What underlies this JavaScript idiom: var self = this ?

I saw the following in the source for WebKit HTML 5 SQL Storage Notes Demo: function Note() { var self = this; var note = document.createElement('div'); note.className = 'note'; note.addEventListener('mousedown', function(e) { return self.onMouseDown(e) }, false); note.addEventListener('click', function() { return self.on...

Using Javascript to add HTML?

Hi, I was wondering if it was possible to get Javascript to write some HTML onto the page in a certain DIV. This is due to the fact, there are certain areas of the site where i don't have access to the markup. But i would like to add a small section there. For example the container i want to add some html to is <div id="topics"></div...

Javascript snippet to convert doxygen style comment to HTML

In relation to this question, I was wondering if anyone knows a javascript code snippet/library to convert a single doxygen comment to HTML? For example, /** This is a comment block * * \b bold text * \i italic text */ would be converted to something like: <p>This is a comment block</p> <p><b>bold</b> text</p> <p><i>italic</i> t...

Calculate user’s time using TimezoneOffset

Hi, I am trying the get the user’s local time to store into my database. I cannot use PHP function now() as it returns the server’s time. I have got the TimezoneOffset by using JavaScript: d = new Date(); alert(d.getTimezoneOffset()/60); How can I calculate the time by using this? And what type should I use for MySQL data type? Than...

ASP.Net MVC, Submit a form using javascript

I have a form on one of my ASP.Net MVC views that I created using the following code <% using (Html.BeginForm(null, null, FormMethod.Post)) Using this code I have no control as far as I am aware of setting the name of the form. I'm now trying to write a javascript function to submit the form, is this possible without knowing the form...

Smooth animation in javascript

Is there a way to draw smooth animation in javascript? In directx I'm using the vertical synchronisation. Can I achieve this in a html canvas? ...

How to add some HTML to every HTML document served?

I need to add a script before the </body> tag, so instead of modifying all the pages, I was wondering if I could configure the server to add some HTML before that tag for every HTML document being served? ...

Put cursor on a YUI SimpleEditor

Hello, I would like to be able to put the cursor wherever I want inside an instance of YUI SimpleEditor. The problem is that I am using setEditorHTML after every keystroke and the cursor moves to the beginning of the text every time. Different commands in YUI do it already but I don't want to have to create a command for it if possible....

How to make a DIV section clickable?

I have written a web page in which links are all contained within their own tags. I've also made them all button styles with CSS (border, background color, padding). How do I enable the whole DIV to be clicked to activate the link? ...

SWFobject on top of JS tooltips

http://richarcade.com/play/gunrun I'm using swfobject.js (richarcade.com/swfobject.js) to display Flash content, and wz_tooltip.js (richarcade.com/wz_tooltip.js) to display hovered tooltips. The problem is that the 'similar games' tooltips show up behind the flash game. Any ideas? ...

Why doesn't this Javascript work with Opera or Chrome?

Hi All, Thanks for reading. I have several scripts that are built similar to the following: scriptone.js function FunctionOne(){ // Do a bit of work... // Include a second javascript file, scripttwo.js // that contains a function called FunctionTwo.js var scrb = document.createElement('script'); scrb.type = 'tex...

Is there an automatic jQuery plugin updater?

Is there some sort of utility available that will check my jQuery plugins and see if they are the latest version? I understand that there is not an easy way to check the version numbers automatically; but I wonder if anyone has taken a look at this. ...

pre-compressed gzip break on chrome, why?

I serve pre-compressed CSS and JS files on my site, and IE6-8 and FF is working perfectly with my .htaccess file. # Compressed files RewriteCond %{HTTP:Accept-Encoding} .*gzip.* AddEncoding x-gzip .gz AddType application/x-javascript .gz AddType text/css .gz I call the files with the .gz extension already [example]: <link rel="styles...

How can I call a function in an iframe's parent using Greasemonkey

I have a Greasemonkey script which adds an iframe to the page (call it Page 1). The iframe contains another page (call it Page 2). The script runs on Page 2 as well. Pages 1 and 2 are on different domains. I'd like to allow code running in Page 2 to call a function on Page 1. Given the lower restrictions on Greasemonkey code, is thi...

Is it correct to use JavaScript Array.sort() method for shuffling?

I was helping somebody out with his JavaScript code and my eyes were caught by a section that looked like that: function randOrd(){ return (Math.round(Math.random())-0.5); } coords.sort(randOrd); alert(coords); My first though was: hey, this can't possibly work! But then I did some experimenting and found that it indeed at least see...

Javascript and ASP.NET with Visual Studio OnMouseOver Control Validation Error

Hello: I just started working with Javascript and I ran into an error with Visual Studio stating, "Validation (ASP.Net): Attribute 'onMouseOver' is not a valid attribute of element 'Button'". Basically, I entered onMouseOver="this.style.color='Red'" within the HTML code of a button control. When I run my web project, the mouse over co...

Certain sIFR Selectors not working in Safari--extremely unusual bug:

I am creating a site, CardinalCoffee.com, using sIFR. It's not quite ready to go, so access by adding 72.249.85.228 cardinalcoffee.com 72.249.85.228 www.cardinalcoffee.com to your /etc/hosts (C:\WINDOWS\system32\drivers\etc\hosts on Windows). On the blog page (http://cardinalcoffee.com/blog/), and only on the blog page, certai...

How to Show One <div> if Javascript Enabled and a Different <div> if It's Not?

I'm using some Javascript to display a "photo fade rotator" in a <div>. If JS is not enabled, however, I've got an animated gif I want to display instead. I actually have it working with this code: <div id="slideshow" class="show pics float-left"> <img src="images/banner-photos/new-01.png" width="343" height="228" alt="photo" /> ...

Finding javascript's origin.

Is it possible from a Javascript code to find out "where" it came from? I needed this to provide scripts that could run folder-agnostic, e.g.: http://web1/service-a/script.js http://web2/some-folder/service-b/script.js And they're linked in: http://web1/page1.html http://web2/page2.html The file script.js is identical in both loca...

Show animation in a jsp page while waiting for server to respond

Hi everyone, What would be the best way to display an animation while waiting for server-side processing of a jsp page to complete.Basically, the server side request can take more than a minute to process and until then I would like the user to have some way to get an update of how his request is getting along.I require an animated gif ...