I had a look at sIFR.js code after parsing it and I have a question
about function syntax. For example
var f=function(){
// statements here
}();
What is the purpose if the second set of parentheses following the
closing brace? Is the intention to execute the function immediately
after it has been defined?
Most functions in sIFR.js do not have this syntax, but a few do.
I have this particular problem with eval() when using Microsoft Internet Explorer, when trying to define an event handler. This is the code:
function BigObject() { this.items = new Array(); this.values = new Array(); this.addItem = function( item ) { this.items[this.items.length] = item; } this.makeHandlers() { var i, length = this.items.length; for ( i = 0; i < length; i++ ) this.items[i].onclick = function() { alert( this.values[i] ); }; }}
However, this last code (makeHandlers() method) doesn't work since the expression "this.values[i]" automatically belongs to this new anonymous function, and therefore isn't valid (since the new anonymous function(s) don't have the "values" attribute. So I tried the following:
and it worked! ... in Firefox only :( Internet explorer returns "undefined" for eval( "function() { /* whatever */ ); } " ), for the same things Firefox perfectly understands, and if I try to make it a handler, an exception is fired in IE. What do I do? Did I come to the right conclusion with IE or am I making a banal mistake? Do I need to find another way of solving this or is there a fix to this solution?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html>
[code]....
The practical scenario is I have several functions attached to the jQuery ajaxSucess event. Each function needs to execute once during initial load and after when the JQuery ajaxSuccess event is fired. So I am just looking to see if I can eliminate a a few lines of code and learn something new in the process, that is really all.
just a quick question about syntax.What's the difference between the following functions?
$("#menu li").hover( function(event) { if ($(this).is(".active")) return;
[code]...
If you notice, at the end of the first hover function, there is an excess (), whereas on the second, there isn't. They are both functional. I was just curious as to why this is added sometimes and other times not.
My Javascript is very limited, but I get on pretty well with Jquery (I love it!) so some of what I say here may be seriously flawed I've done alot of searching on this but not found anything that fits what I need (I'd rather write and understand my own code than use a plugin) What a want is a simple function (or other means) of replicating the callback function for lengthy animations (so I don't end up with a load of functions within functions within functions) So I want to be able to animate (or change) a multiple number of elements IN TURN - ie once the previous animation has completed - eg
I know I can do this with callbacks, but as I said, this gets messy Can I stick these in an array and pass to a function to manage this (and if so how baring in mind my limited Javascript
Throughout the world in general, ISO 8601 Week Numbers are used, in which weeks are numbered 01 upwards and Week 01 contains the first Thursday of the Gregorian Calendar Year.
There are, however, odd parts of the world where that standard is not followed.
Ignoring for the moment cases in which week 1 is not more-or-less at the beginning of the calendar year, what other definitions, stated exactly, are used?
i'm a newbie on jquery i'm studying it with the latest version, and following a book called "Learning Jquery" but iencountered a error, and i don't know what the problem is:
i copied the code from the book like this:$('a[@href^="mailto:"]').addClass('mailto'); to try to change the links which start with "mailto" to the new class "mailto" but there's a error reported: uncaught exception: Syntax error, unrecognized expression: [@href^="mailto:"]
I'm trying to grab all of the elements of a DL, specifically the <a href>'s grouping them by the DD's. I suppose if I can just get them into groups I can get the href's later. The hard part is getting them grouped as explained below. For example...
Is there a way to say, loop through the DL until it finds a DT. Whe it finds one, grab it and all of the DD's that immediately follow it .. until it comes to another DT. Group it with its DD's and continue until no more DT's are found.
Then maybe take these collections and possibly populate an array with the groups?
There is an effect I would like to do but I don't know how it is done. To see something like it go to:[URL].. then mouseover the right side items under "most recently". It seems like there is a dt link which when mouseover occurs the dd data is presented.
I have pairs of terms and short definitions in a table. I want to display a longer definition in a box below the terms table when the term is clicked on. The box needs to disappear if clicked on. [code]...
Sorry but I can't get the very first tutorial to work. I put the custom.js in a test_jr directory in htdocs. I also put the starterkit.html file in the same directory. I copied the contents of jquery-1.4.4.min.js into a jquery.js file also in the same directory. Then I did the custom.js page shown here:
I tried clicking on the [URL] and I get the starterkit.html page. If I click on the "some link" it doesn't do anything. What am I missing? There are syntax errors in my editor starting on the line with the asterisks* Why is there an error there? It looks like it closes the click function?
I am trying to use multiple instances of this little show/hide script for a definition list on the same page. However, the problem is that the definition list must be given an ID, and this can only be used once on a page. [URL]. How would I go about changing this to a class so that I could use it more than once on a page (i.e. multiple definition lists as opposed to one big one)? I changed all of the getElementById to getElementByClass and it didn't seem to work.
so i wrote this slider with some help from an admin, everything works as I would like it to but I'm trying to make it a plugin so i need to tighten up a certain part of the code:
(function( $ ){ $.fn.jmSlider = function() { // get total width of all li elements in the slider var wrapWidth = 0;
[code]....
what i would like to do is instead of using "li:first" and "li:last", i would like to use first-child and last-child so the element doesn't need to be a li, in can be anything that is the direct child of the parent container.
I've got a website with font sizes using 'em's. I've made it so that in my 'body' CSS styling, I can change the font size and it changes it right throughout the whole site.
I have hyperlinks to increase and decrease the font size but have no idea how to get the links to change the 'font-size' property in my 'body' definition. As a secondary requirement (but not essential) I also need to remember this value and store in a cookie so the user doesn't need to keep resizing the page on every reload.
I've always wanted to help second-language English speakers access my site better, by offering a 'double-click on a word' definition in other languages. I had a useful script for some years which was rather dated, and ceased to work if there was an iframe on the page for some reason. Anyway, I found a very good solution at [URL]However, this opens the definition in a new tab/window.
Having experimented with it opening in a popup, I found problems in getting the popup to regain focus if someone had not closed it before looking for another definition. And anyway, popups can get blocked. So I found a nice layer/iframe solution at [URL] though their positioning of the layer is poor, at least in FF because it slides too far down below the bottom of the page. Their script is: [URL]I have modified that to work with dictionarist and stripped out their own floating part of the script, so that it works with position fixed for everything except IE6. But for IE6, I need to still change this from position fixed to position absolute, and then use a script to float the box.I have been trying the script I use successfully elsewhere in a vaguely similar context:
which has a call to startFloat(); near the end, which is based on their own floating script nearer the top of [URL] which I have removed. (Doubtless the references to Netscape (RIP) can be removed.)
I am doing a distionary page with javascript and I am trying to get it so that the definitions come up when the word they are for is clicked on.
Here is my javascript Javascript Document var filename = "dictionary.js"; function loaded(which){ alert(which + " loaded"); }/**/ function showInfo(which){ var placeholder = document.getElementById("definition"); var source = whichInfo.getAttribute("href"); placeholder.setAttribute(source); alert("showInfo called"); return false; }function prepareList(){ if (!document.getElementsByTagName || !document.getElementById) return false; var words = document.getElementById("words"); if (!words) return false; var links = words.getElementsByTagName("a"); for(var i = 0; i < links.length; i++) { links[i].onclick = function(){ showInfo(this); return false; }} alert("prepare list done"); }function init(){ prepareList(); }loaded(filename); window.onload = init;
Here is my html <!DOCTYPE html PUBLIC "-W3CDTD XHTML 1.0 StrictEN" "[URL]"> <html xmlns="[URL]"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Dictionary DOM Scripting</title> <link href="../styles/main.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="dictionaryScripts/dictionary.js"> </script> </head><body> <div class="page"> <div class="nav"><ul> <li><a href="../home.html">Home</a></li> <li><a href="../form/form.html">Form</a></li> <li><a href="dictionaryCSS.html">Dictionary with CSS</a></li> <li><a href="dictionaryDOM.html">Dictionary with DOM scripting</a></li> <li><a href="discussionPage.html">Discussion</a></li> </ul></div><div class="header"> <h1>Dictionary with DOM Scripting</h1></div> <div class="mainContent"> <div id="words"><h2>L</h2> <p>Click on the word to get a definition</p> <dt><a href="lecturer.html">LECTURER, n.</a></dt> <dt><a href="learning.html">LEARNING, n</a></dt> <dt><a href="liar.html">LIAR, n.</a></dt> <dt><a href="love.html">LOVE, n.</a></dt></div> <div id="definition">Choose a definition</div> </div></div></body></html>
I am looping through an array of objects and creating an <li> element for each one and appending to a <ul> in the DOM. Works fine.During the looping I am also attached a 'details' object as data for the list element:$(thisListItem).data('details',{<obj>});Later, I am using the selector:$('ul#images_list li')to attach an on click function for each <li> element.In the click handler I am reading the data 'details' object for the <li> element:dataDetails = $.data(lotImage,'details');and, using the jAlerts plugin, I am opening a jPrompt which asks for the user to enter a price.
The jPrompt call includes a callback which receives the entered value as a parameter. The callback uses the value to 'post' the updated value, via $.ajax, to a server side unction.After OK is clicked in the jPrompt popup, in Firebug, I get an error that the dataDetails is undefined and it lists the line number in the click handler where I originally read the data object from the <li> element.I don't really understand why it should care after the click event has fired and the jPrompt callback has been invoked
I have a simple hide and fadeIn. When you rollover a word it will reveal the definition. The problem I am having is if you move the mouse around quickly from one word to the next word sometimes it gets hung up and a definition will not hide. The result gives this hanging defintion and whatever the other definition the mouse is rolledover.
Here is the code I'm using:
There are about 70 words in a box with the definition being reveals on the right hand side. Is there a way of making sure there is always only one definition being shown?
if the dt-element in one of the definition lists has a specific css-property (e.g. length > 100px) then the dd-element with the css-class "subtitle" in the same definition list should be removed.
I am trying to order a laptop from the Dell online shop but everytime I try to press 'continue' after picking the options, I get an error message in the lower left hand corner of the browser. I'm using WIN 98SE with java enabled on my laptop.
I would assume there's a bug in that line. Although there's little I can do about it other than forward it to the Dell folks - my pgming background has me curious as to what's causing this!