javascript

Accessing a text file from another domain?

Hi, I'm trying to get at a text file from an external website, for use with scripts running from my own domain. Example: // run from www.mysite.com: <html> <head> <script> function blah() { var data = document.getElementById("thedata"); alert(data.innerHtml); } </script> </body> <body> <emb...

Changing adjacent cells in table when an event is triggered in JQuery

Hello, I'm trying to make a game of lights out. I can get the lights to toggle on and off when i click them, but i am having trouble thinking up logic to make the adjacent one come one as well. For example if i click an edge of the table, I should see the three lights adjacent to the light i clicked, become lit. I'm thinking maybe it has...

Javascript "window.open" code won't work in Internet Explorer 7 or 8

I am using this chunk of jQuery/Javascript code on my site to open a popup window: $('#change_photo_link').click(function(){ $id = $('#id').attr('value'); window.open("photo.upload.php?id=" + $id,"Upload Photo", "menubar=no,width=430,height=100,toolbar=no"); }); This code works on Firefox and Chrome. It does not work on ...

Why do I see JavaScript variables prefixed with $?

This is sort of a meta-question. Many snippets of JavaScript I've seen here on SO are named with a dollar sign prefix (for example, $id on the second line of the snippet shown in this question). I'm not referring to jQuery or other libraries. I am well aware that this is valid, but it seems awkward to do when not necessary. Why do pe...

How to get file name when user select a file via <input type="file" />?

I've seen similar questions before,which ends up with no solution,because of security reasons. But today I see hostmonster has successfully implemented this,when I open a ticket and attach a file in their backend. It works both with firefox and IE(version 8 to be exact). I've verified it's exactly client side scripting,no request is s...

javascript restricting???

is it possible to restrict javascript libraries from being able to manipulate the dom? im trying to create a system that has a main system with the api which will be able to manipulate the dom and then i want to give the ability to create third party scripts but have them limited to only the api functions. ...

How do I pass in config info to CKEditor using the jQuery adapter?

I'm using the latest CKeditor with jQuery adapter. I have successfully got it to work, and display. However, as I am completely new to CKeditor, how do I pass in config variables using the jQuery method? This is what I've got $( '#input-content' ).ckeditor('', { toolbar: 'basic' }); I think from what I've rea...

Script to find if a similar question exists

G'day, I'm creating an FAQ system, and the user needs to be able to see if a similar question has been asked. Just wondering if anyone knows of an scripts (php or javascript preferably, or possibly actionscript) that has some kind of AI that will do this? I've noticed on stackoverflow as a question is typed, related questions are given ...

Access javascript function in a programatically iFrame

Hi, I am trying to access a javascript function in a programatically created iFrame from a javacript function outside. I tried several ways, but was not successful. like window.frames['frameid']. etc. Could you please provide me a syntax, ...

can we change Description in zend framework in client side with jquery or javascripts?

i have created a form with zend framework and this form have some elements that all elements have a description , i set description with setDescription in design time, i want to know can i change this Description in client side with jquery or javascripts? ...

How can we resolve conflict between prototype and jQuery ?

To resolve a conflict between jQuery and prototype is there any way other than asking jQuery to resolve via jQuery.noConflict and using jQuery instead of $('code').code; Cant we ask prototype $ to step down and resolve. ...

How to make jquery autocomplete to work for a contenteditable DIV instead of just INPUT, TEXTAREA fields.

The jquery autocomplete provided by http://docs.jquery.com/Plugins/Autocomplete can work on a INPUT field or a TEXTAREA field. I have a use-case to make a DIV element act as a TEXTAREA by setting its attribute to contenteditable="true". Can I use the DIV's DOM handle for the autocompleter to behave as a textarea for the autocompleter. Cu...

How do disable options from the Format menu in CKeditor?

In the Format select box, you can choose Heading 1, Heading 2 etc How can I disable some of those options? Is it also possible to rename them? I want to only allow Heading 2 and Heading 3, and if possible, rename them to Heading and Sub-Heading. I figured out how to rename them - in the language file. I edited the 'en-au.js' and then s...

Are an element's dimensions readable immediately upon adding it to the DOM tree?

Suppose I dynamically create a DIV using document.createElement, add some inner text, and want to determine its height and width. I can see that before adding the DIV to the DOM tree, properties such as offsetWidth and offsetHeight are 0, which is expected. Once it is programmatically added to the tree, can I expect those properties to...

code-style: Is inline initialization of JS objects ok?

I often find myself using inline initialization (see example below), especially in a switch statement when I don't know which case loop will hit. I find it easier to read than if statements. But is this good practice or will it incur side-effects or a performance hit? for (var i in array) { var o = o ? o : {}; // init object if it...

Sliding menu on mouse over

All, In the following code <body> <div id="slidemenubar"> <a href="">1</a> </div><br> <div id="slidemenubar2"> <a href="">2</a> </div> </body> On mouse over hyperlinks 3<br>,4 <br>,5 should be show on the right side(like sliding menu) On mouse over 2 6<br>,7 should be shown in the sliding menu and the new menu shoud be towards righ...

How do I inject a script URL containing an ampersand with ASP.NET?

I have a server control that needs to programmatically inject a JavaScript reference into the page. It is to reference Microsoft's Bing map control which requires &s=1 to be appended to the script URL for use over SSL. The problem is that the .NET Framework encodes the attributes and changes the & to an &amp; (verified with Reflector). A...

Can a single script be used for two or more Anchor button clicks?

In my page there are two 'Conatct Selected' anchor button, one at the top having id as "selectAllLink" and other at the bottom having id as "selectAllLinkB" of the page. The top one working perfectly using the following script: <script type="text/javascript"> $(function() { $('#selectAllLink').each(function() { var a = []; ...

"The stylesheet was not loaded because its MIME type, "text/html" is not "text/css".

I have a javascript application and when I run it on firefox I am getting the following erro on the console: "The stylesheet was not loaded because its MIME type, "text/html" is not "text/css". DumbStuck!! EDIT: Note that it tells that "The stylesheet ABCD..." But ABCD is actually an HTML file. Edit (ANSWER) : Actually I had ...

jQuery live confirm

Hi, I'm having problems with .live() and confirm. It's multiplying the confirm dialogs for every click. I know about .die() but i can't get it to work. $("button.del").live("click", function(){ if(!confirm("Are you sure?")) { //close } }); I've tried $("button.del").die("click"); right after the abov...