javascript

How to tell if browser/tab is active

I have a function that is called every second that I only want to run if the current page is in the foreground, i.e. the user hasn't minimized the browser or switched to another tab. It serves no purpose if the user isn't looking at it and is potentially CPU-intensive, so I don't want to just waste cycles in the background. Does anyone ...

PHP-generated javascript and quote marks

I'm generating some javascript in my PHP code, and I need to assign some php variables to javascript variables. Unfortunately, sometimes my PHP variables contain quote marks. for instance: $foo = "'Dis here be a \"string\""; print "<script type='text/javascript'>var foo = '{$foo}';</script>"; will generate a javascript error because t...

Greasemonkey guide for Experienced Javascript Developers?

I really really want to write a GreaseMonkey extension. I have written a lot of javascript in my life. I am looking for a guide that will tell me quickly, what exactly the GreaseMonkey environment is and does, from the perspective of someone who is familiar with everything going on in browser based Javascript. I.e. no platitudes about...

Facebook Extended Permissions Dialog Dissapears

I'm trying a couple of different ways to show the "publish_stream" extended permissions dialog. Each time I see a blank dialog with title "Request for Special Permissions" show up for a brief few seconds then disappear. I'm doing some very straight-forward stuff: <script> Facebook.showPermissionDialog('publish_stream'); </script> I al...

How can I tell if a javascript object is an Image or a Canvas?

I have a class with a property that can be an Image (i.e. an IMG element) or a Canvas. When I serialize it to JSON, I need to convert this to a text string. If it is a Canvas, then I can call Canvas#toDataURL. But if it is an Image, I first need to draw it to a Canvas with Canvas#drawImage, then serialize that canvas with toDataURL. So ...

JavaScript calender to accept future date only

Is there a calendar control to display only future dates? What would the code look like? ...

jQuery / Javascript - Show / hide ID if current url contains /foo/

Hi Folks, I am using jQuery currently and I am looking for a way to hide if the url contains /blah/. Thanks in advance for your help. I am a js Noob and know it can be accomplished with regex somehow but don't have the time to learn this right now. I have a deadline I need to meet! Thanks, Jack ...

How to get current UTC time in JSON format using Javascript?

Hello, I have a JSON Date for example: "\/Date(1258529233000)\/" I got below code to convert this JSON date to UTC Date in String Format. var s = "\\/Date(1258529233000)\\/"; s = s.slice(7, 20); var n = parseInt(s); var d = new Date(n); alert(d.toString()); Now I need to get current UTC Date with Time and convert it into JSON da...

How to get number of rows in <textarea >?

With javascript,is it possible? EDIT let me be more specific. I mean:the exact number of rows in a textarea. Here it's 10 rows in my post. Anyone knows? ...

Changing more than one style attribute with Javascript

I need to change more than one style attribute for a given element. I know how to change one: document.getElementById(today).style.visibility= "visible"; but am unsure of the syntax for changing more than one e.g. visibility,width, height and font-color. ...

What is the best way to go about creating a page of stickies with savable and retrievable content?

I have had a look at sticky notes with php and jquery and jStickyNote, and while both seem to look pretty nifty they lack some elements I am after. I haven't been able to find a way to allow particular users to modify the stickies they create, nor have I found a good way to save their stickies into my database. I am, and would like to ke...

javascript Button.click() does not work in firefox. works fine in Internet Explorer

I have asp.net button on my page. When I click the button using javascript (buttonId.click()), firefox seems to fire all onclick eventhandlers on the page. I would like to click only one button. This scenario is working fine in Internet Explorer. Please let me know of any workarounds for this. Thanks ...

PHP stylesheet print switcher problems?

I have this print style sheet switcher i created a long time ago and know it wont work for some reason, its suppose to switch to a print style sheet when the link is clicked and display the print dialog box. But know it will only display the dialog box in FireFox and not in any other browser and will not display the print style sheet at...

How To: Displayed image file name different than actual filename on server.

I would like to display an image but have the file name different than the actual file name on the server. ex) The user would see <img src="/img/photos/Awesome_Picture_By_John.jpg"> by looking at the source code but the actual file name would be /img/photos/12b7dch2.jpg any help is appreciated. Thx ...

regex to remove last line of block of text ..

Hi , how do i remove the last line from a block of text in java script without using loops.(only using regex) eg., "The Internet is a global system of interconnected computer networks that use the standard Internet Protocol Suite (TCP/IP) to serve billions of users worldwide. It is a network of networks that consists of millions of pri...

Jquery history - Ajax navigation - How to make url request and search request?

I'm using the Jquery history exemple: mikage.to/jquery/jquery_history.html I don't really know how to make a search query using a search box form and how to create a search link like: mysearch.php?search=search+term&submit=1 Normal link are usually as follow: load 3 It's probably adding code to the function in the main page but i'...

problem with json and eval

I can't seem to find any solution to this within SO so here goes. I have a call to a WebMethod within the C# of my page like this; $.ajax({ type: "POST", url: "MyWebPage.aspx/jQueryMyWebMethod", data: "{FamilyType:'" + $('.HdnFamilyType').val() + "'}", contentType: "application/json; charset=utf-8", dataType: "json"...

Javascript Textarea Monitoring / Ruby Delta Calculation

I am working on a system which needs to keep constant (and I mean constant) track of browser side changes to a textarea via AJAX requests to the server. Ideally, every character would be stored as a row in the database, along with the position it was inserted and a timestamp. I am hoping that there is either a good Javascript library th...

jQuery scrolling UL with hidden overflow

I have a UL with LI's set to display horizontally. The UL has a fixed width and it's set to hide the overflow. This is so I can display my images, which are to be used in a gallery, neatly. It works and looks nice. I want to, however, use jQuery to scroll the contents of the UL rather than set the overflow property to auto and be presen...

Problem in displaying all images inside the folder using javascript

Hi, For my project I m using jquery bulit in photo slide show,jquery code is taking images from array and displaying the images..The problem is I have a lot of images which I don't want to put it in Array(because it need manual effort) instead of that I want to read each image from the folder and display the images. the advantage of doi...