javascript

How do I extract a background= value from a string containing HTML in JavaScript?

I have a string containing HTML loaded from another page, how do I extract the background property from it's body tag using Javascript? The body tag in the string looks like this: <body onload='init();' background='storage/images/jsb_background.jpg' link='#000000' vlink='#000000' alink='#000000' leftmargin='0' topmargin='0' marginwidth...

Sproutcore: Changing css properties on mouse events

In sproutcore I'm trying to change the border thickness of a div when a user mouses over it. All the other code is working but I can't find how to either access the css properties directly or attach a new classname to the div. borderDiv: SC.View.design({ layout:{top:60, left:60, width: 400, height: 525}, classNames:"panel", ...

How to I preload images where it actually forces the images to load before continuing (html/javascript)?

I want to preload images but ensure they are loaded before continuing. How can I do this? The following does not work as it sends off the load request only, but doesn't wait till the image is loaded. So it is possible that the image isn't loaded when requested soon after. jQuery.preloadImages = function () { for (var i = 0; i <...

explaination of object javascript

I am looking at javascript file and they started it off as var myPage = new Object(); var myDocument = document.all; then there is some code. and then this part myPage.Search = myDocument.Search; myPage.Search.searchType = "Description"; I am using eclipse with aptana. I want to know why would someone wanna do this myPage.Search =...

Assigning function within function object without invoking the function itself.

Dear experts, I am trying to assign an function within an function object property without actually invoking then function itself. for instance, I have the following function object class definition function objectOne(name, value, id){ this.name=name; this.value=value; this.id=id; this.methodOne=methodFunction(this);...

Using javascript, show a certain amount of divs based on an answer

I'm building a form that first asks if you have 'foo'. If the answer is 'Yes', a div appears and asks 'How many foo do you have'? Based on the quantity answered, I'd like to show only that many divs. Thus if the user answers 1, only the first div will show. If they answer three, the first three will show. I have it set so that if the use...

whats this javascript function doing

pg.testSearch.searchString.onkeyup = function(){ pg.testSearch.btnSearch.setState(); } ...

How to set the max width for images in a page in a cross browser way?

css or javascript are wilcome thanks. ...

javascript function

can someone explain what this function is doing var page = new Object(); page.testSearch.btnSearch.setState = function() { this.disable(!(page.testSearch.searchString.value.trim().length > 1)); } thanks ...

ClearInterval with a click

Hi Everyone, I have been working within another question on this site and have almost completed what I need to accomplish. I have 30 divs that slide in and out on an interval. What I am trying to achieve is that when an anchor within each of these divs is clicked it should stop the rotation. In the other question page it has been sugge...

Prevent <img> tags in HTML from wrapping

Hi all, I have a javascript that dynamically creates many <img> tags, and appends them to various divs. I want to prevent these images from wrapping; when the screen resolution is not enough to contain them the browser should create horizontal scroll-bars. Sorry for this bad English. ...

How to declare JavaScript and CSS XHTML-compatible?

Hi! I'm wondering how to declare JavaScript code within a CDATA section so that it is compatible with XHTML. Which method is correct/recommended? Method 1: <script type="text/javascript"> // <![CDATA[ CODE // ]]> </script> Method 2: <script type="text/javascript"> /* <![CDATA[ */ CODE /* ]]> */ </script> Is the second one also sui...

Addthis: Sharing for unique items on page

I am using addthis (addthis.com) to offer sharing on items listed on a page (stage.hverdagskupp.no). Since each item on the page is unique, I want the shared information to be unique as well. However, facebook and twitter only seems to allow global page information to be shared. Anyone knows how to define item specific sharing informa...

How to change link if JS is disable and enable ?

I need if JS is enabled then this link will be this <a href="#" class="collops">see sitemap</a> And is js is disabled then link should be this <a href="http://stackoverflow.com" class="collops">see sitemap</a> ...

Why am I losing my characters from my html string when trying to add html dynamically using javascript

I have a page that I am trying to dynamically add some links to. The links are getting added to the page fine, but the '[' and ']' at either end of the line are getting dropped. The code from my .js file is: var html = "[ <a href='#'>Change</a>&nbsp;|&nbsp;<a href='#'>Remove </a> ]"; $(html).appendTo("#id123"); The result I want is: ...

jQuery JSONP, only works with same site URLs

I need to make a request to an API which returns json formatted data. This API is on a sub-domain of the domain this script will run off (although at the moment it's on a totally different domain for dev, localhost) For some reason I thought that jsonp was supposed to enable this behavior, what am I missing? Using jQuery 1.4.2 $.ajax(...

Per pixel collision detection in Javascript/Jquery/Gamequery

I am trying to program a web game in Jquery with the GameQuery plugin, problem is the GameQuery plugin has no support for per pixel collision detection only collision detection with bounding boxes. Is it possible to implement per pixel collision detection in javascript/Jquery? I have a world map with countries and a player which is mov...

javascript how to simulate function global scope for Json statement?

javascript how to simulate function global scope for Json statement? var testJson= { a1: 1, a2: this.a1+1 } and the result should be: var testJson= { a1: 1, a2: 2 } ...

jQuery getScript function with frames

Hello.. I'm a novice at Javascript/Jquery programming, so an apology if this is a simple/silly question. I am trying to use the jQuery .getScript() function to refresh part of an existing webpage. This webpage must be run on a local file system, and a large amount of the formatting is done using frames. Right now, there’s three main ...

Need help to figure out which layout to use ?

Hello I need some help on understanding layouts better. I watched some of the screencasts and the examples, etc. But I can't get done what I need and I think I'm not understanding things correctly. I want to create a page with a Grid on top with a 100% width of the viewport. (Actually in my real page it's in a specific div but let's ju...