javascript

Resource (JS, CSS) compression, minification, and versioning in ASP.NET.

We’re coming to a big release in a web project I work on, and I’m starting to think more and more about javascript/css performance and versioning. I’ve got a couple high level ideas so far: Write (or customize) an http handler to do this for me. This would obviously have to handle caching as well to justify the on the fly IO that wou...

Problem detecting Newlines in JavaScript Range Object

I have some javascript that manipulates html based on what the user has selected. For real browsers the methods I'm using leverage the "Range" object, obtained as such: var sel = window.getSelection(); var range = sel.getRangeAt(0); var content = range.toString(); The content variable contains all the selected text, which ...

Comment reply procedure using jquery and php?

I have Commenting system in my app. For a single video entry anyone can post a comment and someone else can post reply to that comment and replies, cannot have thier further reples, similar to StackOverflow is doing (1 Answer, and thier 1 or more replies). I want the similar functionality what SO has, Let's I have the following HTML <...

Scrolling down to next element via keypress & scrollTo plugin - jQuery

I am using jQuery's scrollTo plugin to scroll up and down my page, using UP arrow and DOWN arrow. i have a bunch of div with class "screen", as so: <div class="screen-wrapper">...</div> What I am trying to do is, when i press UP or DOWN, the window scrolls to the next, or previous div with class of "screen". I have the keypresses take...

How to get abc from "abc def"?

"abc def" "abcd efgh" If I have a large string with a space that separates two substrings of varying length, what's the best way to extract each of the substrings from the larger string? Because this is a string rather than an array, array syntax s[0] will only retrieve the first letter of the string ('a'), rather than the first subst...

How to use a global selector to respond to all click events except on one element?

If I have a button: <button id="button1"> Normally I would write: $("#button1").click(function () { //do something } But I want to define a function that responds to all click events except when someone clicks on this button. Is there a selector that would allow me to target all other clickable elements in the document ex...

Calling javascript function from dropdownlist

Is it possible to call a JS function when a specific a item is selected from dropdownlist? ...

Javascript opening maximized window when unintended

Hey. The following line was opening a 490x610 window, but after modifying some other code, it started to open up the full page new window. Any ideas as to why? <a href="cart_display.php" onclick="window.open('uploader/upload_files.php?order_id=32063700', '','width=490,height=610')">Upload Here</a> ...

Being someone new to AJAX, what would be a good place to start?

Being someone new to AJAX, what would be a good place to start? What books/tutorials would you recommend? ...

javascript using variable value in document.nameofformtosubmit.submit()

How would I submit the id into the form name to submit a certain form? function submitComment(id) { alert('comment on song id: '+[id]+''); document.postcomment.submit(); } I want to be able to submit.. postcomment43 or postcomment 42.. whatever the value of ID is joint to postcomment Tried this: function submitComment(id) ...

Validate Plugin - using the submitHandler

My apologies if you have already seen this or replied to it but I can't seem to find the question I originally submitted and i'm desperate for a solution. I need to display a promotional message when the user clicks submit if they meet certain criteria about their postcode. I have heard that you should use the submitHandler but being...

How to get IntelliJ IDEA to display directories?

I've been trying out IntelliJ IDEA for JavaScript editing and I'm liking it so far, but I'm having a small problem with a new project. I can't seem to be able to get IDEA to display the directories in the project dir in the Project view. Even if I manually add a directory, it refuses to display it. I think this probably has something t...

correct way to use variables in the javascript DOM

What is the correct way to format the document.formToSubmit.submit() line? var formToSubmit = 'postcomment' + id; alert( ''+ formToSubmit +'' ); document.formToSubmit.submit(); The formToSubmit variable seems to be correct but the submit() does not work. ...

How do I preserve the form value after refresh browser?

I have one simple JSP having four buttons ( Button1 , Button2 , Button3 and Button4). The button value set into hidden field when I click on button. I need to get the latest button click value after refresh the page ( preserve the button value). could anyone please help me ? <script> function one(tab){ document.getEleme...

height of page in javascript

I'm unable to get the height of a page in javascript when the page is larger than the screen. I thought this would get me the right height: $(document).height(); but that only gets the height of the screen, same as: $('body').height(); same as: document.offsetHeight; For some reason all these examples only return the height of ...

How to use Javascript math on a version number

I use jQuery to get the browser version like this: var x = $.browser.version; I get a string like this: 1.9.1.1 Now, I want to do an evaluation so if x is >= 1.9.1 then do some stuff. Unfortunately, with multiple decimal points, I cannot do a parseFloat() because it converts 1.9.1.1 to simply 1.9, and the if evaluation would match a ...

Correct syntax for defining an event delegator

Normally you write a handler for a button click like this: $(document).ready(function() { $("button").click(function() { doSomething(); }); }); But in the case of an event delegator, to respond to an event with a function such as this: function doSomething(event) { if (ev.target.id == 'button1' ) { /...

Using jQuery to circumvent tabindex problems

I'm trying to control my forms and how the user interacts with them via the form elements' tabindex property. All of my elements have tabindex specified, and I want this value to be respected and used properly. I'm currently developing on Mac/Firefox and I'm aware of the default Mac system setting that sets tab-switching to only input e...

How should I display a table with an XML data source?

I had a CSV file that I converted to XML. I would like to use this data for a table on my web page. What is the best way to tackle this? Thanks. Mike ...

Detect Visitor Browser view port size with Javascript and Save to a PHP variable.

Hi there. I almost sure that PHP can't detect the View port size of a browser right? But since that, can someone teach me how can i do it with Javascript and then gather that size from a Javascript variable to a variable in PHP? Regards PS: Sorry if there is another post with the same question. ...