javascript

innerHTML size limit

I want to use AJAX to load an htmlfile into a <div> I will then need to run jsMath on this. Everything I have done so far with innerHTML has been a paragraph or two, maybe a table and/or image. Nothing too fancy. What potential problems may occur when I set innerHTML to an external 25k file, with all sorts of complex css formatting?...

jquery match() variable interpolation - complex regexes

I've already looked at this, which was helpful to a point. Here's the problem. I have a list of users propagated into an element via user click; something like this: <div id="box"> joe-user page-joe-user someone-else page-someone-else </div> On click, I want to make sure that the user has not already been clicked into...

Dynamic content in 2 columns (rather than one!)

Hello, I have one table which display data as from Dynamic Content in 1 column. I would like the content to move to a second column when the number of cell is >3. (ie. if there are 3 cells to display, it would be display in 1 col, and 4 cells or more it would be displayed in 2 columns. Note that the dynamic content will never go over 6 ...

JavaScript variable scope question: to var, or not to var

Hi All, Many thanks in advance. I'm working out of a schoolbook and they're using one function to call another which opens a window: function rtest(){ content='dans window'; oneWindow=open("","Window 1","width=450,height=290"); newWindow(oneWindow); } function newWindow(x){ x.document.close(); x.document.open(); x.do...

Find out when the window.location.href of an iframe has changed with javascript (jquery)

The question sums it up really... I have a parent page with a child iframe, How do you find out when the location of the iframe has changed, i.e. a user has clicked on a link in the iframe and the iframe is navigating to another page I know I can bind to the onload event of the iframe like so $("#theIframe").load(function(){ //Do ...

Drawing pixels based on mouse position

Scenario: I have an area on the browser screen n x n in size (500px x 500px for example, ie 250,000 pixels). As the mouse rolls over the area, it "paints" the pixels it passes. Percentage of filled/unfilled pixels are displayed Optional advanced scenario: As the mouse rolls over already painted pixels will "unpaint" those pixels, or pa...

How do I dump JavaScript vars in IE8?

I have an object I need to examine in IE8. I tried the developer tools and console.log, their Firebug equivalent. However, when I output the object to the log: console.log("Element: ", element); console.log(element); I only get the string LOG: Element: [object Object] instead of a clickable, examinable dump. Is it possible to dump...

How to avoid the unsaved form warning in Safari

Safari has a feature to prompt you if you're sure you want to close/refresh the page on which there are some forms which you typed into. This is useful in most cases, but in this case it's bugging me. I'm hijacking the "submit" event on some forms and sending them to the server via XMLHttpRequest. However, Safari doesn't know that, so w...

What is the "event" parameter that so often is defined for JavaScript event handler functions?

A lot of time I see jQuery code that looks like this: $('a').live( 'click', function(event){ .. }); What does the event parameter do? Does it correspond to the element 'a' or the event 'live'? ...

if Ajax request don't finish, html links can't click

I have a jquery ajax request in my website page, and every page i need to post this request to server to get the status. But it have a issue: after i open the page in browser, before this request return the data, my page all link can't works, they can't click.But it render normal. so anybody have a solution for that? such as: make the pa...

string => number conversion in JS

I have a URL, that I am parsing after the hash. The content after the hash is a math equation (eg. http://example.com/something#5+1) which I would like to find the sum of (or the result of any other equation like a product, division, etc) I can retrieve the numbers using: var url = (window.location.hash).substr(1) // returns "5+1" as a...

Loading external page using jquery/ajax - loading external page's jquery scripts as well.

Ok, this is killing me. I'm loading an external page with jquery: var response = $.ajax({ url: "example.php", dataType: "html", async: false, }); $("#content2").empty().prepend(response.responseText); This part is working perfectly. Now I know that if I I want to interact with the new content I would have to bind any...

"Expected ]" error while passing an object as parameter to js function

I am trying to pass an object as parameter to the javascript function as: .html('<span class="link" onclick="javascript:ShowEventDetails(' + event + ',' + event.Id + ',' + event.Name + ',' + view + ')">' + event.title + '</span>') In the above js, the event and view are objects from the jquery calendar Full Calendar, which i...

What language/script can I use to embed a .M4V file into a webpage?

I'm trying to embed a .M4V video file on a web page and it seems to disagree with all my attempts. I need it in this format as it is for someone else's ongoing project. I am trying to use this java library file to initialize/talk with: <script type="text/javascript" src="qtobject.js"></script> Here is my code attempt (not working, b...

Fix incorrect nesting

function drawinventoryList() { inventoryArray.sort(); var inventoryString = ""; for (x in inventoryArray) { arrayValue = inventoryArray[x]; var counter = parseInt(x) + 1; if (counter == 1) { inventoryString = "<table width='100%' celpadding='0' cellspacing='0' style='border:1px solid #d00;'...

Why does a global variable captured in a $.get() callback closure always hold the same value?

I'm having a bit of trouble capturing the value of a global variable in my $.get() callback: Relevant markup <div class="block" id="blog"></div> <div class="block" id="music"></div> <div class="block" id="video"></div> Relevant code $('div.block').each(function() { $this_id = $(this).attr('id'); alert($this_id); // outputs: blog...

JQuery: $.get is not a function

Hi, I'm having a problem doing something very basic in jQuery. Can someone tell me what I'm doing wrong exactly? If I run the code below, the function $.get seems to be missing (getJSON and others missing too). But $ itself and other functions do exist, so I know JQuery is loading. google.load("jquery", "1.3.2"); function _validat...

open a url using java script for Ubiquity command

Hi, I was writting a Ubiquity command but I have 0 expriece on JS. How to open an url (http://www.stackoverflow.com for example ) using JS? EDIT: Thanks you all, I believe you are correct, but with following code I was not be able to jump to so. It might be something related with Ubiquity but It was declared to be JS. CmdUtils.Create...

How to get current time in the format 2009-12-24 14:20:57 in javascript?

I'm not familiar with time operations in javascript. I tried new Date(); which gives the result in wrong format: Thu Dec 24 2009 14:24:06 GMT+0800 How to get the time in format of 2009-12-24 14:20:57? ...

Iframe content problem

Please help me out, The very first time the iframe height is changing as per the loaded height but when the iframe contents are changed to bigger height than the present one and again coming to lower its not taking new value. For example Loaded iframe height =1386px new content change iframe height = 3440px and again change to new he...