javascript

Invoking jQuery function without an element

So, I use jQuery quite extensively and I am well aware of the "right" way to do the below, but there are times where I want to solve it in a more generic way. I'll explain. So, I may have a link, like this: <a href='menu' class='popup'>Show menu</a>. Now, I have a jQuery function that fires on click for all a.popup that takes the href-a...

jQuery ajax function to call php script which returns a value?

Hello! Thank you for looking at my issue, hopefully you can help me out as I'm an not well versed in writing JavaScript functions and am relatively new to using jQuery... Anyways, I need a way to use jQuery's ajax call to asynchronously call a php script which will return a value and update the value in a header element. Anyone know of...

Read a text file

I have looked everywhere and surprisingly can't find a good solution to this! I've got the following code that is supposed to read a text file and display it's contents. But it's not reading, for some reason. Am I doing something wrong? FTR, I can't use PHP for this. It's gotta be Javascript. var txtFile = new XMLHttpRequest(); txtFi...

SVG Filters in Firefox

For some reason I can't get my SVG filters to work in Firefox. They work fine in Opera, however. The element whose property I set to the filter on just disappears. It's very odd. Here's my javascript code: defsElement = SVGDoc.createElement("defs"); var filterElement = SVGDoc.createElement("filter"); filterElement.setAttribute( "id", "...

How to add to a javascript var array using content_for in Ruby on Rails?

Right now in my code I'm calling content_for like... <% content_for :javascript do -%> <%= "var boxplot_data=#{@survey.boxplot_answers.to_json};" %> <% end -%> Rather then having to convert a whole array at once I'd rather add to the array boxplot_data and then have it display as a var. That way I can make my code easier to read...

Select Objects in Array Based on Regex Match

How can I return only the objects in an array that meet a certain criteria using javascript? For instance, if I have ['apple','avocado','banana','cherry'] and want to only output fruit that begin with the letter 'A'. EDIT: Took Sean Kinsey's function below and tried to make it more flexible by passing in the array and letter to match:...

Permission Denied using Javascript/jQuery on a local file

function publish(text) { $('#helpdiv').prepend(text); } function get_help(topic) { $.get(topic, publish); } <p>Hi. <a href="#" onclick="get_help('inline-help.html'); return false;">click here for more help.</a></p> <div id="helpdiv"></div> I've inherited this chunk of HTML and javascript above (snippet). It is/was going to be use...

Javascript, AJAX, Extend PHP Session Timeout, Bank Timeout

Greetings, I have the following JS code: var reloadTimer = function (options) { var seconds = options.seconds || 0, logoutURL = options.logoutURL, message = options.message; this.start = function () { setTimeout(function (){ if ( confirm(message) ) { // RESET TIMER HERE $.get("renewSession.php...

jquery, if hovering over an element injects something into the DOM, can I still reference it?

if hovering over an element injects something into the DOM, can I still reference it? Or do I have to use the live plugin? i' using jqeury 1.3.2 i.e. can I do $("#someItem").attr("src", "htt..."); on it? I am trying to do it, but I think its not working b/c its a newly added item to the DOM. ...

Subdomain and Uploadify not working

I have wildcard subdomains for example: .example.com goes to example.com/app/ It seems uploadify works fine if I use the directory instead of the subdomain. But when I use the subdoman and click on the upload image nothing happens. It seems to load the flash fine and no JS errors but when I click on the button I do not get a file brows...

'Calling a method' OR 'sending a message' in Objective C

In C or any ECMAscript based language you 'call a public method or function' on an object. But in documentation for Objective C, there are no public method calls, only the sending of messages. Is there anything wrong in thinking that when you 'send a message' in ObjC you are actually 'calling a public method on an Object'.? ...

JSF form does not get submitted when form is disabled by JavaScript

This is the submit button: <h:commandButton actionListener="#{regBean.findReg}" action="#{regBean.navigate}" value="Search" /> This is the form: <h:form onsubmit="this.disabled=true;busyProcess();return true;"> If the submit button is pressed, the page shows a "busy" icon until request is processed. The problem is, the f...

Using Javascript in Google Web Optimizer Page Sections

Is it possible to use Javascript in the content of a page section variation? I want different variations to make different Javascript function calls, so I have variation content like: Variation 1 <script type="text/javascript">my_func('abc');</script> Variation 2 <script type="text/javascript">my_func('def');</script> However, whe...

I need help to disable shadowbox from resizing

This overlay seems to be the only overlay plugin that works within my schools wonky template... but the problem is that when the browser is resized the shadowbox resizes too, clipping the contents inside. I want it so the box stats fixed and if the browser does get smaller the browser will have scrollbars. I know it's been modified befo...

Detect shaking when using the draggable interaction

Something like this perhaps? $('#drag').draggable({ shake: function(){ alert('Shake event invoked'); } }); ...

Complex JavaScript. What called me?

Project I'm working on uses jQuery. I have a series of Ajax calls being made that load() other HTML fragments which in turn load() other fragments. The whole thing is confusing. I didn't write the code. Is there any tool which will allow me to walk the callstack so I can figure what is calling a method? any browser tools that would he...

How do you detach your pageload from third party scripts?

I have this problem where the UI components of my page like the drop down menus arent available until thirdparty scripts finish loading. This causes a problem because who knows whats going on on those servers. I need to detach the availability of the page's interactive components from the loading of thirdparty stuff... how? =/ ...

Conflict between some JavaScript and jQuery on same page

I am using a JavaScript function and some jQuery to perform two actions on a page. The first is a simple JS function to hide/show divs and change the active state of a tab: This is the JS that show/hides divs and changes the active state on some tabs: var ids=new Array('section1','section2','section3'); function switchid(id, el){ ...

How to add <font> with Javascript?

FM_log(3,"rp_insertTable() called"); var farmTable = dom.cn("table"); var ftableBody = dom.cn("tbody"); var i; var maximize = GM_getValue("Maximize_" + suffixGlobal, 0); farmTable.className = "FMtbg"; farmTable.id = "farmMachineTable"; farmTable.setAttribute('cellpadding', 2); farmTable.setAttribute('cellspacing', 1); f...

Dynamically moving div, like Yelp's moving map

I am trying to implement something very similar to Yelp's moving map. See: http://www.yelp.com/search?find_desc=restaurants&amp;ns=1&amp;find_loc=mountain+view%2C+ca Basically it starts off somewhere in the middle of the page, but if you scroll down far enough that you wouldn't be able to see it, it moves down as well. What is the be...