javascript

Invoking Link in Javascript or jQuery

I have an href taged object (graphic) on a page that I want to programatically click on. However,I can't figure out how to reference the object. Here is the tag: <div id="getthebutton"> <div> <a onmouseout="MM_swapImage('btn123','','http://www.comp.com/img/btn_img.png',1)" onmousedown="MM_swapImage('btn123','','http://www.comp.com/img...

How can I change the style of multiple elements using jQuery?

I have one CSS style sheet with rules like this: h1, h2, h3, h4, .contentheading, .title{ font-size: 13px ; font-weight: normal; font-family: Arial, Geneva, Helvetica, sans-serif ; } The tags, classes are generated by plugin so i can't add a single class to it. So, is there any way that I can change the styles of all elements at ...

Caching complex jquery selector based on parent & type

I'm trying to speed up jQuery performance. I found some questions/answers on this site to help but I'm trying to take it a step further... Here's an example of the HTML, quite simplified <div id="Container"> <div> <div> <input type="text" id="something"> </div> <input type="text" id="other"> ...

Javascript + namespacing + FF issue

var utils = function() { function getMyPrivateName() { return "Caoimhin"; } return { messages: { getMyPublicName: function getMyPublicName() { return "Kevin"; }, sayHello: function() { document.writeln("hello " + getMyPublicName() + "<br/>"); ...

Converting from jquery to prototype

Hi all- I have the following jquery I'd like to convert to prototype. I am having some real trouble getting it working because I can't figure out how to initialize it correctly in a rails app. $(document).ready(function(){ /*** Search label ***/ htmlinput = $("input#panel-search").val() /* picks the inital value of the input ...

ASP.NET Ajax string format help please

Hi All, I have the following javascript code and I am not getting the result I want. I am trying to format a string using String.format(format, args) like c# works. I have var claimNum = $("#ctl00_DefaultContent_txtClaimNumber").val(); var claimant = $("#ctl00_DefaultContent_lblClaimClaimant").text(); var param...

JavaScript: Capturing Enter key WITHOUT JS Framework

How can I detect when the "Enter" key is pressed in the window, and conditionally suppress it? I've found lots of solutions with jQuery and MooTools, but not a frameworkless version. Thanks! ...

Javascript DIV style height (IE and FF) with jQuery

In IE, using jQuery I set the height of a DIV nicely: $('[id$=divBahai]')[0].style.height = 123; The same code run in FireFox and Safari does not alter the height of the Div. I put an Alert() after the code to display what the style.height was and it was blank in FF and Safari. It came up as "123px" in IE and displayed right. Is ther...

jquery how to make sure that all the images has been loaded

var nowCount = 0; $("img").load(function(){ imgCount++; if (nowCount == imgsCount) do something ... }); imgsCount :: the number of images that i want to load 1- is this code compatible with all browsers ? 2- how can i know if an image failed to load ? ...

Why is my text changing size randomly

A little disclaimer before I get ridiculed for not putting up code examples: I would have to put my whole site on here so there is nothing really specific except a combination of PHP,CSS,JAVESCRIPT,and XHTML that creates 70 plus pages Basically I am just looking for a guess on what it could be making my text change sizes randomly. I can...

Javascript rich text editor textbox for an XUL App

The functionality i am trying to implements will allow user add notes and format it with bold/italics, etc. using XUL app. Any suggestions would be greatly appreciated. Thanks PS: i have done searches on this site and have found multiple editors TinyMCE, webkit, FCKeditor. What i wanted to know is if anyone used any of these editors ...

how to update a Django page without a page reload ?

My Django app displays data from a database. This data changes without user intervention, i.e. behind the scenes. Whenever it changes, I would like the webpage to update the changed sections without a full page reload. Obviously AJAX springs to mind. When the page is loaded initially (or manually, fully re-loaded later on), the rendered...

How do I make it so that there is no "Ghost" when I drag an image in Firefox?

When you drag an image , there is a semi-transparent ghost image that follow your mouse when you hold it down. Is there some way to apply CSS/JS to remoe this effect on a certain portion? ...

Difference between innerText and html()

Hi all: I was wondering whats the difference between innerText and html()? Thanks. ...

Pull javascript code from tag using js or jQuery

How would I retrieve the javascript call in the anchor tag below in JS or JQuery? Basically I want to get the code ("javascript:do_my_function('blah', 'string1', 1);") retrieved so I can execute it. This anchor is embedded several deep in some div tags as well. <a onmouseout="swapImage('btn1','','http://img2.comp.com/img/buttons/btn_g...

(js) passing whole object into onclick method rather than a string

<div class="rating" onclick="swapImg('bad')"><img id="bad" class="unselected" src="img/unrated.gif"/></div> my javascript is passing the entire img object into swapImg, and not the string 'bad.' for example, if i console.log(param) the param being passed into swapImg, i get: <img id="bad" class="unselected" src="img/unrated.gif"> wh...

What is the best way to search for an item in a sorted list in javascript?

I have an ordered list of integers, and would like to search through them. What is the fastest way to do this? Is this the fastest it will work? Or can we optimise it because it is ordered? Array.prototype.Contains = function(value) { for (var index = 0; index < this.length; index++) { if (value == this[index]) { ...

Howto Prevent IFraming w/ Whitelist

I'm creating some IFrameable content. We want the user to be able to IFrame this page, but only from a set list of domains. Is there anything that we can check to see what the domain name of the parent page is? if (top != self) { top.location.replace(self.location.href); } ...

javascript - image not switching in browser after i change source

function swapImg(imgId) { var image = document.getElementById(imgId); if (image.getAttribute("class") == "unselected") { image.setAttribute("src", "img/frownie.gif"); console.log(image); } } if i look at what's outputted to console, the src of the image is correct. but it's not changing in my browser. what's up? ...

Should I place Jquery files on my web server or just refer to them via jquery.com in my PHP files, which is better?

When I use Jquery or its plugin, should I just add <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt; <script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/validate/jquery.validate.js"&gt;&lt;/script&gt; Or should I download both files and upload both to my web serv...