javascript

attachEvent versus addEventListener

I'm having troubles getting the attachEvent to work. In all browsers that support the addEventListener handler the code below works like a charm, but in IE is a complete disaster. They have their own (incomplete) variation of it called attachEvent. Now here's the deal. How do I get the attachEvent to work in the same way addEventListen...

Can one Chrome extension enable or disable another one?

I have a chrome extension that very simply injects CSS before a page loads. (I know this could be done by javascript once the page has loaded, but this causes the page to flash as it changes/renders the new CSS.) The CSS is injected as a content script using code like: "css": ["mystyles.css"], "run_at": "document_start", I would ...

Why might Chrome return an incorrect MIME type error for one of my JS files when they are all served the same way?

I'm getting an error reading one of my JavaScript files ("Resource interpreted as script but transferred with MIME type text/html.") from Google Chrome. The other three JS files that my page calls load just fine, and I'm confused about what is causing this problem since they are all marked up in exactly the same way (and each has a "typ...

Weird problem with jquery serialize: data get cut in certain circumstances

I'm using serialize in .post request and it looks like this $.post(this.action, $(this).serialize(), null, "script"); In the form there is a textarea with the name 'comment'. The problem is that when I put first string in double quotes, followed by end line and then some text server recieves only first string without quotes. For i...

Difference between ID and control.ClientID OR why use control.ClientID if I can access control through ID

This is the code from .aspx file <html xmlns="http://www.w3.org/1999/xhtml"&gt; <head runat="server"> <title>Login Again</title> <script type="text/javascript"> function Validate() { if (document.getElementById("txtLogin").value == "") { alert("Enter login name."); } ...

Does google analytics slow down my website?

I am at the final stages of my website, and currently I need to find a suitable statistics application/tool. I have looked into webalizer, but it seems outdated. Also, I have looked into Google analytics, but I am afraid that if I implement it, my website will go slow. It is already pretty heavy with database material being displayed w...

JavaScript object with internally referenced properties

I'm trying to create a global object with a series of 'slave' properties that are derived from the value of one 'master' property in the same object - something like: var x = 5; var myObj = { master : 17, slave1 : this.master + x, slave2 : (this.master / 2.2) + 1, slave3 : Math.floor(this.slave2) //etc. }; I realiz...

Impossible to add addEventListener onClick to SWFObject

Problem: Need onclick event to pause/unpause a Youtube video, but impossible to add the evenlistener. Looks to me that the object is 'unclickable'. Situation: Got a Youtube player initialized by swfobject, onYouTubePlayerReady is build as suggested in the docs (Google API docs) For HTML & JS see: http://ListAndPlay.com What I tried: al...

Batch export indesign file to pdf with custom footer for each client.

I have a fairly large Indesign file with a text field that needs to have a different text for each client. The name of the client must come in the text field. When I have for example 100 clients, I want to automaticly export 100 PDF's and each PDF has its own custom text in that field. The name of the client must be appended to the filen...

map geo coordinates (lat, lng) to map (x, y)

I have the geo-coordinates (latidute & longitude) of some cities and would like to get the x,y coordinates so can plot them into a map. The map is a standart one, just like http://www.wordtravels.com/images/map/Spain/Fuerteventura_map.jpg for example. I tried several formular I found, but none seems to really work :(. Simple javascrip...

dynamic html forms radio buttons

I am working on a dynamic form. The form has 3 radio buttons. when you click on radio button 1, a drop down populates. when you click on radio button 2, a drop down populates. etc after the user has clicked on the radio button on part 1, there is another radio button that asks the user if they want another try. eg. another radio button...

Why does java/javascript/python force the use of () after a method name, even if it takes no arguments?

One of my most common bugs is that I can never remember whether something is a method or a property, so I'm constantly adding or removing parentheses. So I was wondering if there was good logic behind making the difference between calling on an object's properties and methods explicit. Obviously, it allows you to have properties and me...

Creating custom file dialog for bulk photo upload

Is it possible to customize the "Browse UI window" which always open when we upload photos / files? I want to acheive two things: In the bottom it always says "All Files". I want to lock that to only .jpg, .jpeg, .png so only those files types can be selected for upload. Secondly extent that box so when the upload is complete the previe...

Array splice throws error in IE

IE7 and IE8 are not letting me splice my array (Safari, Chrome, Firefox work): lzaCreateAd1.weatherArray = new Array(); var jWeatherIcon = $('.weatherIcon'); jWeatherIcon.bind('click', function (){ var targetID = $(this).attr('id') + 'Box', idVal = targetID.substr(5,1); var j...

How can I test if a URL is a valid image (in javascript)?

When submitting a form, I want to make sure a field is a valid image URL. I could make an AJAX endpoint on my server which CURLs the URL and parses the output with an image library, but that feels a bit of overkill. Could I get away with making an <img> element then synchronously check the response somehow? ...

Dynamically loading CSS

Hey There, I'm trying to create a page theme function for my site. I want to load the corresponding themes dynamically on the page using separate CSS files. I'm using this code: fileref.setAttribute("rel", "stylesheet") fileref.setAttribute("type", "text/css") fileref.setAttribute("href", 'link.css') document.getElementsByTag...

Exclude Literal backslash in Javascript Regular Expression

Hey, I'm writing a php forms class with client and server side validation. I'm having problems checking if a literal backslash ("\") exists in a string using regular expressions in javascript. I want to shy away from solutions other than using regex as this will reduce the amount of special cases between php and js AND reduce the amou...

What's the best way to find tbody rows in javascript? Regex or ...?

What I want to do is to filter a table to only show the tbody that contains a given value against a value entered into a textbox, and to show the filtered rows in a zebra stripe pattern. The zebra striping is fast, the filtering is generally fast, except on the first filter on a table with a lot of tbodys (say 2000 tbody? ... I haven't ...

jquery not working in wordpress

Wordpress is not loading jquery - I think it may have something to do with the fact that it is loading the files absolutely, not relatively, and it won't go to the url (firebug is saying access denied to restricted uri). I have tested vanilla javascript and that works, however as soon as i try to do even the most basic function in $(docu...

Home Baked Google Instant (Just the fancy AJAX)

Anyone know how you could duplicate the instant nature of Google Instant? I'm trying to create a similar functionality with hand carved results (basically a huge if statement) on a website. Some more clarification: If a user were to type 'phone' in a search bar, contact information would instantly appear below. more clarification: I d...