javascript

PHP/APACHE: can i auto_prepend to a .js file?

I'd like to auto_prepend_file all my js files with: var SITE_ROOT = 'http://www.mydomain.com'; Can this be done in .htaccess like it can for php files, if so, how?!!! ...

Queued message sending with Prototype.AJAX

Hi there, is there any best-practice-pattern for implementing a queue for sending ordered requests? I know this hits the logic behind ansynchronous requests, but in special cases one needs queued sending :) Here is my first attempt: this.queue = [], this.sending = false, send: function(message) { if (this.sending) { this...

Smart String Replacements

This works well for case insensitive replacements: str = str.replace(new RegExp(phrase, 'gi'), '<span style="color:red;">' + phrase + '</span>'); But what I do want is to not change case when replaced which above-mentioned does. ...

How can I improve my coding style?

Hello, I have been using JavaScript and jQuery a lot lately and I think I can do just about anything I want with it by just Googling and reading tutorials... But often I notice that my coding style differs a lot from what's provided by other people, for example I only just recently found out about shorttags for if/else statements. Or I ...

Javascript + jQuery, applying a blur effect to background images

Is there a way to apply a "blur" effect on a background image in Javascript/jQuery? [edit] By "blur" I mean a Gaussian/Motion blur not a drop shadow :) Thank you. ...

jQuery in Wordpress doesn't work?

I'm trying to put some simple jQuery code into the Wordpress header (usually just use CSS) but no matter what I try I cannot seem to get it to work. The code is: <script type="text/javascript"> var fadein = 300; var fadeout = 200; $(document).ready(function(){ $("#btnforum img, #btnfacebook img, #btntwitter img, #btnyoutube img, #btnli...

path- and other problems using node.JS and Socket.IO

Hi, I'm using node.JS in VirtualBox on a TurnkeyLinux hosted by Windows. I was following the instructions here. node.JS is living in /root/node. Although I can run simple examples successfully I'm having a hard time figuring out certain things, cause I'm not a Linux-guy normally. I wanted to use socket.io. I managed installing node.JS...

How to secure the Javascript Code ???

Possible Duplicate: how to prevent your javascripts being stolen,copied, and viewed ? Hi What is the best way to secure the javascript code & make it hard to understand it and for sure steal it... I know that its impossible to secure it 100% since its client side and all the code the client can see it.. But I need to make it ...

Why does adding two decimals in Javascript produce a wrong result?

Possible Duplicate: Is JavaScripts Math broken? Why does JS screw up this simple math? document.write(.1 + .2) // 0.3000000000000004 document.write(.3 + .6) // 0.8999999999999999 The first example is greater than the correct result, while the second is less. ???!! How do you fix this? Do you have to always convert decimal...

find the type of html controls in javascript

How to find the control type in javasccript?. Say if i have an ASP.NET LinkButton and i wanna find control type from the javascript. How can i do that. I tried using typeof(), but it giving me an object back. and i tried var control = document.getElementById(Id);//Id is the ClientId of the Linkbutton alert(control.type);//this is empt...

synchronizing executeSql in Safari (WebKit) Web Sql database

WebKit (Safari 4+ is my focus) has a feature called Web SQL. Web SQL is specified in the W3C draft Currently only the asynchronous flavor is supported. I have a situation where I want to synchronize couple of operations - writing to database (using CREATE TABLE query and then a loop through INSERT queries) and then reading from the dat...

javascript only runs once

This script only runs once. I click a button and it changes the menu. I click another button and it doesnt do anything. I tested this with both buttons going first than second. function deelnemersmenu(optie) { if (optie == "deelnemers") { var menuHtml = "<div class='profielmenu_item_current' id='deelnemers_item_deelnemers' o...

value of button using javascript

I have 3 buttons in my form. All the button actions goes to a same page after clicking it depending upon what button is clicked. My query is: The name of the buttons are 'add','edit' and 'remove' When the 'add' button is clicked, using js I need to get the value of that button and similarly for the other two buttons.... Can you plea...

When trying to remove any selected option in an select element, Safari shows it as blank

Examine this code. I'm using jQuery, but I think it is probably irrelevant. JavaScript ​$(function() { $('button').click(function() { $('select option[selected]').removeAttr('selected'); }); }); HTML <select> <option>a</option> <option selected="selected">b</option> <option>c</option> </select> <button>give...

How to replace a js file path in my php page using PHP?

How to edit js/swf file path in my php page using PHP code. Path is not unique it is varying. I have to search these file path and replace it. Any body knows the solutions please help me. ...

jQuery: How to cancel blur event if the element that will receive focus is a particular type?

I'm writing a custom form UI and currently building a select box replacement. The custom select control is basically a div with a hidden (off screen) select input in it, along with a span containing anchor elements mirroring the options of the select input: <span class="input select"> <span id="select-select1" class="select-input...

Deleting properties of DOM elements

Is there a way to delete properties of DOM elements? I'm using a widget that upon rendering itself adds tabindex attributes to certain nodes. I'd like to remove them because they cause unwanted visual changes. I tried the following which does not seem to have any effect (tabindex stays the same): delete domNode.tabIndex; domNode.tabInd...

How to avoid "Cross-Site Script Attacks"

How do you avoid cross-site script attacks? Cross-site script attacks (or cross-site scripting) is if you for example have a guestbook on your homepage and a client posts some javascript code which fx redirects you to another website or sends your cookies in an email to a malicious user or it could be a lot of other stuff which can prov...

how do i namespace pseudo-classical javascript

Hi, I have some simple OO code I've written that I'm playing with: //define a constructor function function person(name, sex) { this.name = name; this.sex = sex; } //now define some instance methods person.prototype.returnName = function() { alert(this.name); } person.prototype.returnSex = function() { return this.s...

Javascript/Regex for finding just the root domain name without sub domains

I had a search and found lot's of similar regex examples, but not quite what I need. I want to be able to pass in the following urls and return the results: www.google.com returns google.com sub.domains.are.cool.google.com returns google.com doesntmatterhowlongasubdomainis.idont.wantit.google.com returns google.com sub.domain.google.c...