javascript

Why is ColorBox not loading properly?

The error I get is: $ is undefined Line 8 which is: $.colorbox({html:'<p>TEST TEST</p>'}); This is how the page renders: <script type="text/javascript" src="/sites/all/modules/jquery_update/replace/jquery.min.js?Y"></script> <script type="text/javascript" src="/misc/drupal.js?Y"></script> <script type="text/javascript" src="/sites...

Setting focus on an HTML input box on page load.

Hi there, I'm trying to set the default focus on an input box when the page loads (example: google). My page is very simple, yet I can't figure out how to do this. This is what I've got so far: <html> <head> <title>Password Protected Page</title> <script type="text/javascript"> function FocusOnInput() { document.getElementById("...

fixed positioning and user-scaling on mobile webkit.

The basic problem I have is how to keep something on the screen on Safari at all times, while still allowing the user to zoom/pan etc. The full version is that I am writing a bookmarklet, so it needs to work with as many websites as possible. The overall goal is to have my div show up, anchored to one of the screen edges at all times. T...

Right Click Detection for Firefox

Before beginning, I am not inquiring about stopping users from right-clicking. This is for right-click detection on a html5 canvas. So currently, what I have is: function init() { var canvas = document.getElementById('canvasID');\ if (canvas.getContext) { ctx = canvas.getContext('2d'); ctx.font = '10px sans-serif'; ...

Jquery if div doesn't exist

I'm using 1 js for 2 different pages. 1 page doesn't have a div which the other does. So when I submit the values, I get a $( js error for $('.description'+save_id+'').html(description_val).show(); //update category description I suspect that I get the error because there is nothing to show(). Is there a short code I can use to detec...

Dual login: One login, 2 servers

Okay, this just feels plain nasty, but I've been directed to do it, and just wanted to run it past some people who actually have a clue, so they can point out all the massive holes in it.....so here goes..... We've got this legacy site & a new public beta-test one. Apparently it's super cereal that moving from one to the other is seamle...

Passing values to formmail.cgi without refresh (HTML form PHP handling)

My host has a formmail.cgi script to send html form data to emails (http://formmail.dreamhost.com/), but I dont understand how to pass it values that it understands. Ive tried using this method to pass form values: HTML: <form id="contact_form" action="http://formmail.dreamhost.com/cgi-bin/formmail.cgi" method="POST"> <input type=...

When should a period be used after $ in jQuery?

Hi, I am a beginner in JQuery. When should be used point after $ in JQuery? $.trim(str) and not $trim(str)? And some cases without point: $(document).ready, but not $.(document).ready? Thanks. ...

How can I force a DatePicker to be used for input instead of the keyboard on an HTML text input inside a WebView in Android

I am attempting to learn Android development and have modified a sample app that loads a web page in a WebView. The web page contains a text input. I want to use the Android DatePicker to input a value instead of the keyboard. The code below almost works. The DatePicker is displayed but throws an unknown error when I select a date an...

Best way to hide inline CSS and JavaScript from downlevel browsers

What is the best way to hide inline Javascript and CSS from downlevel browsers? ... I see a few variations on a common theme. Are they all correct, or is one approach better than the other? <script language="javascript" type="text/javascript"> <!-- // Forces the treeview to adjust to the new size of its container function resi...

How do I hide a jqGrid column of variable name?

I have a jqGrid column which name may change (is a variable), how do I get the name and hide it? Something along the lines of the below (which don't work) $('#tblGridName').jqGrid('hideCol',4); or var infoName = $('.ui-jqgrid-htable th:eq(4)').text(); $('#tblGridName').jqGrid('hideCol',infoName ); ...

Going from Javascript to a rails action

I currently have a city that someone will enter into the system and I want to go from my javascript action to a rails action so i can get the city.id from the database. For example my javascript function get_city(city){ //city comes in like "Washington DC" } my rails action def return_city_id @city = City.find_by_name(params["...

What the best way to check arr, object, string with JQuery undefined + null+ trim(str)!==""?

Hi, 1. What the best way to check array or object with JQuery undefined + null? I check array like that: function f1(arr){ if(arr!==undefined&&arr!=null){ //code } } Is Jquery have better way? 2. What the best way to check String with JQuery trim(str)!==""? I check String like that: function f2(str){ if(str!=...

Does JavaScript allow getters and setters?

this is my code: <script type="text/javascript"> var Note=function(){} Note.prototype = { get id() { if (!("_id" in this)) this._id = 0; return this._id; }, set id(x) { this._id = x; } } var a=new Note() alert(a.id) </script> this style is like to python , this is my first...

How can I use the addonblur setting on the Mootools TextBoxList?

I am using Mootools TextBoxList for a project. I was attempting to set the addonblur option so new tags entered would automatically be added to the list when the text box looses focus. However, I am unable to determine the correct syntax for how to set this. I read the documentation several times and tried different things, but couldn’t...

JQTouch form redirect

How might I implement a simple form redirect using JQTouch after hitting "submit"? Thanks! ...

Why can't I assign a variable inside a function in Javascript?

Very new to JS here. When I write PHP I have no problem assigning variables inside a function, but inside a JavaScript function it doesn't work. Why? example: function hello() { var animal = 'Dog'; document.write(animal); } ...

controll browser tab index

I'm building a window widget using Javascript, when the window is focused, I want the tab control only stay inside the window widget not jump back to the browser. is there any tab index which I can use use to control it? ...

Location of parenthesis for auto-executing anonymous JavaScript functions?

I was recently comparing the current version of json2.js with the version I had in my project and noticed a difference in how the function expression was created and self executed. The code used to wrap an anonymous function in parenthesis and then execute it, (function () { // code here })(); but now it wraps the auto-executed fun...

Is it possible to upload Vignette files directly, without using the web interface?

In the project I'm working on, we have web resource files (e.g. JS, CSS, images, etc) stored in Vignette. As a web developer I find this cumbersome to work with, since I frequently update these files, and since each upload of a file requires several clicks and waiting for up to 5 seconds on each click. It would be awesome if I could in...